Results 1 to 6 of 6

Thread: Stuck

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2000
    Location
    Midwest
    Posts
    35

    Cool

    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!

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    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.

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2000
    Location
    Midwest
    Posts
    35

    Exclamation

    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!!!!

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    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

  5. #5

    Thread Starter
    Member
    Join Date
    Sep 2000
    Location
    Midwest
    Posts
    35
    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

  6. #6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width