Solved

Result of DDE-Search in Word

Posted on 1997-12-22
17
283 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
Comment Utility
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
Comment Utility
SURE! I never did this ... gimme a "kick-off" please.
0
 
LVL 4

Expert Comment

by:ozphil
Comment Utility
ok. code coming.
0
 
LVL 4

Accepted Solution

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

Author Comment

by:BBC
Comment Utility
waitin ... :-)
0
 
LVL 4

Expert Comment

by:ozphil
Comment Utility
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
Comment Utility
testing ...
0
 
LVL 4

Expert Comment

by:ozphil
Comment Utility
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
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 
LVL 4

Expert Comment

by:ozphil
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

743 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