macro error 13: Type Mismatch

erin00

New Member
Joined
Jul 14, 2015
Messages
14
I have a macro to gather all text in a website (saw the code from other website). It works on my machine but does not work on others. The runtime error is 13, type mismatch.

I referenced:
Microsoft HTML Object Library
Microsoft Internet Controls
Microsoft Scripting Runtime
Microsoft Forms 2.0 Object Library

VBA Code:
Sub get_temperature()


Sheets("workspace").Select
Set IE = CreateObject("InternetExplorer.Application")
With IE
 .Visible = False
 .navigate "https://www.accuweather.com/en/us/boulder-co/80302/March-weather/327347" ' should work for any URL
Do Until .READYSTATE = 4: DoEvents: Loop

 gettemps = .document.body.innerText
 gettemps = Replace(gettemps, Chr(10), Chr(13))
 gettemps = Split(gettemps, Chr(13))
Worksheets("workspace").Range("A1").Resize(UBound(gettemps)) = Application.Transpose(gettemps)

 .Quit
 End With


End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
get them to check that these references are not missing
 
Upvote 0
You should probably include some error trapping code to make sure the webpage opened correctly

for example, if it didn’t, your Split command might produce a string rather than an array, and a string has no ubound property
 
Upvote 0

Forum statistics

Threads
1,224,019
Messages
6,175,956
Members
452,688
Latest member
spookralls

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