Hi everyone!
I've just recently (today) started to develop VBA code so I decided to sign up here. So first of all I just want to say Hi and say that I'll try my best to contribute all I can to this forum. But for now...I have a problem.
My first task was to write a Macro that would obtain data from a website and output it into another cell. The programming was going great until I ran into MSInet.ocx. The code below shows that I use Inet. I downloaded MSInet.ocx, put it into my system32 folder and registered it using regsvr32. I also added it to references in the Microsoft Visual Basic editor. Whenever I try to run the program though, I end up with a Run Time Error 429: ActiveX component can't create object and it stops on the line: Set inet1 = New Inet
If anyone could help me that would be amazing.
Almost forgot I run Vista 32-bit and am using Office 07.
Code:
Sub Competitors()
'
' Competitors Macro
'
' Keyboard Shortcut: Ctrl+Shift+C
'
Dim country As String
Dim keyword As String
Dim myURL As String
country = Range("A1").Value
keyword = ActiveCell.Value
myURL = "http://keywordresearch.webcertain.com/keywordstats2.php?q=" & Replace(keyword, " ", "+") & "%0D%0A&se=Google." & country & "&lang=1&search=Search"
Dim inet1 As Inet
Dim mypage As String
Set inet1 = New Inet
With inet1
.Protocol = icHTTP
.URL = myURL
mypage = .OpenURL(.URL, icString)
End With
Set inet1 = Nothing
Dim intStart As Integer, intEnd As Integer
intStart = InStr(mypage, keyword & "", "") + 5
intEnd = InStr(intStart, mypage, "")
temperature = Mid(mypage, intStart, (intEnd - intStart))
ActiveCell.Offset(0, 2).Value = temperature
End Sub
Thanks so much in advance,
Philipp