vba code not working properly (Internet Explorer VBA)

RodrigoFinguer

Board Regular
Joined
Jun 13, 2017
Messages
75
Hi guys.

I am using this code for my work:

Code:
[B]Sub Automate_IE_Load_Page()[/B]
[B]'This will load a webpage in IE[/B]
[B]    Dim URL As String[/B]
[B]    Dim IE As InternetExplorer[/B]
[B]    Dim linhas As Single[/B]
[B]    Dim j               As Long: j = 0[/B]
[B]    Dim Elements        As Object[/B]
[B]    Dim Element         As Object[/B]
[B]    Dim Elements2        As Object[/B]

[B]    'Create InternetExplorer Object[/B]
[B]    Set IE = CreateObject("InternetExplorer.Application")[/B]

[B]    'Set IE.Visible = True to make IE visible, or False for IE to run in the background[/B]
[B]    IE.Visible = True[/B]


[B]    'Define URL[/B]
[B]    URL = "https://www.sew-eurodrive.de/os/dud/?tab=productdata&country=DE&language=en_US"[/B]

[B]    'Navigate to URL[/B]
[B]    IE.navigate URL[/B]

[B]    ' Statusbar let's user know website is loading[/B]
[B]    Application.StatusBar = URL & " is loading. Please wait..."[/B]

[B]    ' Wait while IE loading...[/B]
[B]    Do While IE.Busy = True[/B]
[B]        Application.Wait DateAdd("s", 1, Now)[/B]
[B]    Loop[/B]


[B]    'Webpage Loaded[/B]
[B]    Application.StatusBar = URL & " Loaded"[/B]

[B]    'Pega os valores na coluna B[/B]
[B]    Windows("trabalho.xlsm").Activate[/B]
[B]    linhas = WorksheetFunction.CountA(Sheets("Planilha1").Columns("B:B"))[/B]
[B]    For i = 2 To linhas[/B]

[B]    VBA.AppActivate IE.document.Title & " - " & IE.Name, 0[/B]
[B]    IE.document.getElementById("search-input-productdata").Value = Sheets("Planilha1").Cells(i, 2).Text[/B]
[B]    'IE.document.getElementById("search-button-productdata").submit[/B]

[B]    IE.document.forms(3).Item(3).Click
[/B]....... (continuous)

the code works fine there on my work, but in my home the code ignore the "VBA.AppActivate IE.document.Title & " - " & IE.Name, 0" and the "IE.document.getElementById("search-input-productdata").Value = Sheets("Planilha1").Cells(i, 2).Text", so, i have to pull up the arrow so he can read it. At the last line, the code gives me an error (which does not happen on my work). I have no clue, is it references problem? i don't know what to do.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
you can check the reference's at work and home, but are you using the same IE, and versions of excel
 
Upvote 0
you can check the reference's at work and home, but are you using the same IE, and versions of excel

I checked here, i don't have the reference "UIAutomation CrossBitnessHook 1.0 Type Library". That is the only one i don't have. Shoud this be the problem? It is strange that doesn't show any error, the debugger just skips these lines.
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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