|
-
Oct 13th, 2000, 11:40 AM
#1
Thread Starter
Member
I have found a command named "EditFind" that is suppose to let you search a Word or Excel document. I'm having trouble getting it to work. Anyone out there know how to make it work? Also if you know of a way to open a Word and/or Excel document and then search it, please post. Thanks!
-
Oct 13th, 2000, 11:56 AM
#2
Open Word:
Dim hwnd As Long
hwnd = FindWindow("OpusApp", vbNullString)
If hwnd = 0 Then
Set wdApp = New Word.Application
Else
Set wdApp = Word.Application
End If
wdApp is
Public wdApp As Word.Application
You also need to have Microsoft Word n.n Object Library as a reference.
Here's how you find something:
wdApp.Selection.Find.ClearFormatting
With wdApp.Selection.Find
.Text = "Student:"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
wdApp.Selection.Find.Execute
You can find out how Word does most anything by recording and then editing a macro recorded while you are performing the desired function in Word.
-
Oct 13th, 2000, 12:40 PM
#3
Thread Starter
Member
Thanks for your input MartinLiss. I tried what you included and it did not work. It gave me the following error:
Compile error: Sub or Function not defined
I do know about recording action in Word and I found the same info about the Selection.Find command. I modified it but it is not prompting me for text and when I use the InputBox, that doesn't work either.
HELP!!!!
-
Oct 13th, 2000, 12:44 PM
#4
You didn't say which line it was complaining about but I assume it is the FindWindow line. You need to define this in a module
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
-
Oct 13th, 2000, 12:52 PM
#5
Thread Starter
Member
Thanks once again MartinLiss and it was the FindWindow command, sorry about that. Now its not liking the "OpusApp", the error I get is:
Compile error: Invalid outside procedure
-
Oct 13th, 2000, 12:59 PM
#6
Well, the code I posted is from a working program, so if used properly it should work. Either post enough of your code so that i can see what you are doing, or email me your project.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|