[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 334
  • Last Modified:

Result of DDE-Search in Word

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
BBC
Asked:
BBC
  • 10
  • 7
1 Solution
 
ozphilCommented:
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
 
BBCAuthor Commented:
SURE! I never did this ... gimme a "kick-off" please.
0
 
ozphilCommented:
ok. code coming.
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
ozphilCommented:
ill lock the question in the meatime...:)
0
 
BBCAuthor Commented:
waitin ... :-)
0
 
ozphilCommented:
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
 
BBCAuthor Commented:
testing ...
0
 
ozphilCommented:
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
 
ozphilCommented:
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
 
ozphilCommented:
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
 
ozphilCommented:
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
 
BBCAuthor Commented:
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
 
BBCAuthor Commented:
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
 
ozphilCommented:
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
 
BBCAuthor Commented:
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
 
ozphilCommented:
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
 
BBCAuthor Commented:
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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

  • 10
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now