Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 是否从http/ftp导入Module.bas?_Excel_Vba_Excel 2010 - Fatal编程技术网

Excel 是否从http/ftp导入Module.bas?

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

我想通过ftp/http导入模块

例如: ThisWorkbook.VBProject.VBComponents.Import(“”)


我想将模块的代码保存在中心文件中,但我们没有共享驱动器。因此,我想将我的代码上传到某个服务器上,并不时更新。

扩展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

将文件下载到本地临时文件夹并从那里导入。