0
我有大約1000個包含附件的xml infopath文檔。我正在尋找一種方法來通過VBA將信息附件下載到我的驅動器中,但我無法在此找到任何主角。任何代碼或教程將不勝感激。使用VBA將Infopath附件下載到硬盤中
謝謝!
我有大約1000個包含附件的xml infopath文檔。我正在尋找一種方法來通過VBA將信息附件下載到我的驅動器中,但我無法在此找到任何主角。任何代碼或教程將不勝感激。使用VBA將Infopath附件下載到硬盤中
謝謝!
你是什麼意思'下載'?來自網絡?嘗試這個。
Sub Test()
Dim FileNum As Long
Dim FileData() As Byte
Dim MyFile As String
Dim WHTTP As Object
On Error Resume Next
Set WHTTP = CreateObject("WinHTTP.WinHTTPrequest.5")
If Err.Number <> 0 Then
Set WHTTP = CreateObject("WinHTTP.WinHTTPrequest.5.1")
End If
On Error GoTo 0
MyFile = "website xxxx.com"
WHTTP.Open "GET", MyFile, False
WHTTP.Send here is where I stop. This is the error message:
"Run-time error '-2147012867 (80072efd)':
A connection with the server could not be established"
FileData = WHTTP.ResponseBody
Set WHTTP = Nothing
If Dir("c:\test", vbDirectory) = Empty Then MkDir "c:\test"
FileNum = FreeFile
Open "the file I downloaded " For Binary Access Write As #FileNum
Put #FileNum, 1, FileData
Close #FileNum
MsgBox "Open the folder [ c:\test] for the downloaded file..."
End Sub
另外,請看看這個。