开发者

Import data from web site in MS Access

I want to write an import function for importing data from a website into a ms access database. The original data is stored in a mysql database and is available via a remote text file (csv). So all I want is to access this remote file and read it in vba. The code I use is below, but it seems that references are missing. Don't know which reference ActiveXperts.Http needs. Could anybody help?

Thx Ste开发者_开发百科ve

Dim objHttp
Dim strUrl
Dim strData

' Create a HTTP instance
Set objHttp = CreateObject("ActiveXperts.Http")

' Write some information to console
MsgBox "ActiveSocket " & objHttp.Version & " demo."
MsgBox "Expiration date: " & objHttp.ExpirationDate & vbCrLf

Do
   strUrl = InputBox("Enter a URL", "Input", "www.activexperts.com/products")
Loop Until strUrl <> ""

objHttp.LogFile = "C:\HttpLog.txt"

objHttp.Connect (strUrl)
If (objHttp.LastError <> 0) Then
   MsgBox "Error " & objHttp.LastError & ": " & objHttp.GetErrorDescription(objHttp.LastError)
Else
   strData = objHttp.ReadData
   If (objHttp.LastError <> 0) Then
     MsgBox "Error " & objHttp.LastError & ": " & objHttp.GetErrorDescription(objHttp.LastError)
   Else
     MsgBox strData
   End If
   objHttp.Disconnect
   MsgBox "Disconnect."
End If

MsgBox "Ready."


This tutorial says that it needs ActiveSocket 2.4 Type Library.

(the tutorial is for VB 5/6 and not VBA, but the reference stuff should be exactly the same)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜