Results 1 to 2 of 2

Excel 2007 : Runtime error running macro to open IE and search for string

Threaded View

Aaecae Runtime error running macro... 08-04-2009, 06:30 PM
Paul Re: problems with a code 08-04-2009, 10:43 PM
  1. #1
    Registered User
    Join Date
    08-04-2009
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    2

    Runtime error running macro to open IE and search for string

    Hello I am having a problem with this code:
    Sub AutomateIE()
        Dim ie As InternetExplorer
        Dim RegEx As RegExp, RegMatch As MatchCollection
        Dim MyStr As String
         
        Set ie = New InternetExplorer
        Set RegEx = New RegExp
         
         'Search google for "vbax kb"
        ie.Navigate "http://www.google.com.au/search?hl=en&q=vbax+kb&meta="
         
         'Loop unitl ie page is fully loaded
        Do Until ie.ReadyState = READYSTATE_COMPLETE
        Loop
         
         'String to parse google search for a VBAX reference
        With RegEx
            .Pattern = "www.vbaexpress.+?html"
            .MultiLine = True
        End With
         
         'return text from google page
        MyStr = ie.Document.body.innertext
        Set RegMatch = RegEx.Execute(MyStr)
         
         'If a match to our RegExp searchstring is found then launch this page
        If RegMatch.Count > 0 Then
            ie.Navigate RegMatch(0)
            Do Until ie.ReadyState = READYSTATE_COMPLETE
            Loop
            MsgBox "Loaded VBAX link"
             'show internet explorer
            ie.Visible = True
        Else
            MsgBox "No VBAX link found"
        End If
         
        Set RegEx = Nothing
        Set ie = Nothing
    End Sub
    Every time i try to run it comes up with "User-defined type not defined"

    Any ideas?
    Last edited by Paul; 08-04-2009 at 10:57 PM. Reason: Added code tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1