IE Automation using Excel VBA (navigation issue)

Dzirt07

New Member
Joined
Oct 10, 2017
Messages
11
Hello, please help

I'm trying to create macro which will pull data from site
I was using this code for others projects. However, It's not working with http://www.phila.gov/water/swmap/

I think the problem is in
Code:
Set Element = .document.getElementsByName("searchText")

Maybe I didn't choose right element, I don't know

Please help if you can

Code:
Sub Storm_Water()
    Set objIE = CreateObject("InternetExplorer.Application")
    WebSite = "http://www.phila.gov/water/swmap/"
    With objIE
        .Visible = True
        .navigate WebSite
        Do While .Busy Or .readyState <> 4
            DoEvents
        Loop


        Set Element = .document.getElementsByName("searchText")
        Element.Item(0).Value = "1725 Hoffman st"
        .document.forms(0).submit
        '.quit
        End With


End Sub
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Try this.
Code:
Sub Storm_Water()
    Set objIE = CreateObject("InternetExplorer.Application")
    WebSite = "http://www.phila.gov/water/swmap/"
    With objIE
        .Visible = True
        .navigate WebSite
        Do While .Busy Or .readyState <> 4
            DoEvents
        Loop


        Set Element = .document.getElementByID("searchText")
        Element.Value = "1725 Hoffman st"
        .document.forms(0).submit
        '.quit
    End With


End Sub
PS When searching on that address a message pops up, 'Parcel could not be found'.
 
Upvote 0
Thank you for quick reply

Yes, it seems like 1725 hoffman st is not on database anymore

However, when I'm trying to use "6812 old york" ( 100% correct) it simply doesn't show anything :(
The problem occurs after
Code:
[COLOR=#333333].document.forms(0).submit[/COLOR]
 
Upvote 0
This works but only when I step through it, think it might be a timing issue.
Code:
Sub Storm_Water()

    Set objIE = CreateObject("InternetExplorer.Application")
    WebSite = "http://www.phila.gov/water/swmap/"
    
    With objIE
        .Visible = True
        .navigate WebSite
        Do While .Busy Or .readyState <> 4
            DoEvents
        Loop


        Set Element = .document.getElementByID("searchText")
        Element.Value = "6812 old york"
    
        Set Element = .document.getElementByID("searchBtn")
        Element.Click
        '.quit
    End With

End Sub
 
Upvote 0
Norie, thank you for help

I found the solution for my problem

Code:
Sub Storm_Water()    
    
    Set objIE = CreateObject("InternetExplorer.Application")
    WebSite = "http://www.phila.gov/water/swmap/"
    With objIE
        .Visible = True
        .navigate WebSite
        Do While .Busy Or .readyState <> 4
            DoEvents
        Loop


        Application.Wait Now + #12:00:10 AM#
        Set Element = .document.getElementById("searchText")
        Element.Value = "6812 old york"
        .document.getElementById("searchBtn").Click
        '.quit
    End With
       




End Sub
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,431
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top