Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Result of DDE-Search in Word

Posted on 1997-12-22
17
Medium Priority
?
333 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 4

Accepted Solution

by:
ozphil earned 450 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
 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

636 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