Excel 是否从http/ftp导入Module.bas?
我想通过ftp/http导入模块 例如: ThisWorkbook.VBProject.VBComponents.Import(“”)Excel 是否从http/ftp导入Module.bas?,excel,vba,excel-2010,Excel,Vba,Excel 2010,我想通过ftp/http导入模块 例如: ThisWorkbook.VBProject.VBComponents.Import(“”) 我想将模块的代码保存在中心文件中,但我们没有共享驱动器。因此,我想将我的代码上传到某个服务器上,并不时更新。扩展Tim的评论。将其下载到临时文件夹并从那里导入。您可以使用下面的代码下载文件 Need reference to Microsoft Internet Controls 'Example 'myURL = "http://www.server.de/m
我想将模块的代码保存在中心文件中,但我们没有共享驱动器。因此,我想将我的代码上传到某个服务器上,并不时更新。扩展Tim的评论。将其下载到临时文件夹并从那里导入。您可以使用下面的代码下载文件
Need reference to Microsoft Internet Controls
'Example
'myURL = "http://www.server.de/modul.bas"
'savePath = Environ("temp")
'fileName = "modul.bas"
Sub SaveInternetFile(myURL As String, savePath As String, fileName As String)
Dim WinHttpReq As Object
'create XMLHttp object
Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
WinHttpReq.Open "GET", myURL, False
'send request
WinHttpReq.send
'check the status to make sure we succeeded
If WinHttpReq.Status = 200 Then
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write WinHttpReq.responseBody
oStream.SaveToFile (savePath & fileName)
oStream.Close
'import the new file
ThisWorkbook.VBProject.VBComponents.Import(savePath & filename)
End If
End Sub
将文件下载到本地临时文件夹并从那里导入。