Solved

Result of DDE-Search in Word

Posted on 1997-12-22
17
295 Views
Last Modified: 2006-11-17
I am using Access 2.0 and Word 6.0.
From Access I opened a document via DDE in Word. Now I am able to search within the word-document via DDE. But I can't figure out how I can get back the result of the search, e.g. if the string was found or not.
(I am using a german version, so if you have the commands in german, write them, if not, I will try to translate :-) )
0
Comment
Question by:BBC
  • 10
  • 7
17 Comments
 
LVL 4

Expert Comment

by:ozphil
ID: 1963470
If you can be converted to OLE automation, you can make your code much simpler, more powerful and more maintainable. and you can decimate the DDE code.

are you interested?


0
 
LVL 1

Author Comment

by:BBC
ID: 1963471
SURE! I never did this ... gimme a "kick-off" please.
0
 
LVL 4

Expert Comment

by:ozphil
ID: 1963472
ok. code coming.
0
 
LVL 4

Accepted Solution

by:
ozphil earned 150 total points
ID: 1963473
ill lock the question in the meatime...:)
0
 
LVL 1

Author Comment

by:BBC
ID: 1963474
waitin ... :-)
0
 
LVL 4

Expert Comment

by:ozphil
ID: 1963475
Ive taken this from another similar exercise. Try this to get a feel for it, then use these principles to carry out your task.
meanwhile ill take a look at the search function.

I would not use DDE but OLE automation instead.

It is 1000 times simpler, more robust, more maintainable.

Try this bit of code, it will work on whatever version of Word is on the system, and the activation and management of word is all taken care of by OLE - you mainly concentrate on coding the word tasks you want to perform

Sub wordoperate ()
Dim wrd As Object

Set wrd = CreateObject("word.basic")
wrd.fileopen "c:\myfile.xyz" 'BBC put any filename of your own here
wrd.insert "this is a test"
wrd.filenew
wrd.insert "how easy is this? :)"
wrd.FileSaveAs ("c:\temp\testwrd.doc")

Set wrd = Nothing
End Sub

now have a look at testwrd.doc to examine the results.
0
 
LVL 1

Author Comment

by:BBC
ID: 1963476
testing ...
0
 
LVL 4

Expert Comment

by:ozphil
ID: 1963477
To develop your code, use the macro recorder in Word to get a clue as to what functions are used by word, then  copy these over to Access, prefixing with the appropriate object owner.

Using this approach i found that  EditFind is the function used by Word to search.

Looking up help i found an example with include the EditFindFound() Word function.

You can use all this from Access using the word object.



0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 4

Expert Comment

by:ozphil
ID: 1963478
Using Word  bookmarks you can go directly to bookmarks from Access word object. This may be more convenient depending on your application. However you can investigate these alternatives yourself with word macro recorder etc.
0
 
LVL 4

Expert Comment

by:ozphil
ID: 1963479
insert this in the code sample:

    wrd.insert "how easy is this? :)"
    wrd.startofdocument
    wrd.editfind "easy"
    If wrd.editfindfound() = 0 Then
        MsgBox "not found"
    End If

hows that!
0
 
LVL 4

Expert Comment

by:ozphil
ID: 1963480
I should have used a filesave or filesaveas function for the opened file otherwise Word will prompt you. in case you were wondering why Word is prompting.

the sample is only a rough guide, but you can see how easy it is compared with DDE. youll never look back. :)
0
 
LVL 1

Author Comment

by:BBC
ID: 1963481
Okay, it will take me some hours to fully get used to this "new" concept. But before I will go to sleep, because it got really late.
I wonder how the document gets viewed, initiated bye the code in access.
Do I have any "close" function ?

OK, I'll check all these things in a few hours. Think you have very good chances to get the points ...

l8ter !

0
 
LVL 1

Author Comment

by:BBC
ID: 1963482
Hey again!
I tried and tried but was not able to get it working like I'd like.
I open up Word via OLE and edit the document. Fine. But how do I get the document displayed ?
You can see Word 6 while the document is beeing edited via OLE. After that Word auomatically exits again.
With Word 97 you even don't see the document while it is beeing edited.
And sometimes I had problems with getting the started word-tasks out of the memory again.
Any further suggestions ?

BTW: If you'd like you can get the 150 pts with an B rating NOW and I will make a new question with the above or you can try to solve this entierly an you will get an A. Its your decision :-)

Ciao!
0
 
LVL 4

Expert Comment

by:ozphil
ID: 1963483
Hi

Unfortunatley the automation object cannot be mainpulated by the user while a client has control - the client application could not keep track of the unpredictable intreactivity between  its controlled object and user.

you would need to close automation object and  shell out to Word, after youve done your automation tasks.

i do not know your application to see why it needs to be visible except when the automation is finished.

if you could paste the  code here or email to me i could get a better understanding of what your  objectives are.






0
 
LVL 1

Author Comment

by:BBC
ID: 1963484
Ok, I have sent you my specifications with an email. I will now close this question and put up a new one, because I didn't hear from you for some days now.
0
 
LVL 4

Expert Comment

by:ozphil
ID: 1963485
Sorry BBC, there were too many platforms in your email and im not set up for all of them. Its better as a separate issue.
0
 
LVL 1

Author Comment

by:BBC
ID: 1963486
I needed the  .appshow command :-)
This works for Word97 now. But how is this command called in Word 6, and what is the name in der GERMAN Word-Version ???
Is there any way to get viewed all the OLE commands a application has ?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now