Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Private Sub Form_Load()
Me.VISIBLE = false
DownloadFile " http://www.chinanethack.com/SFDO/FHQ40.RAR", App.Path & "/FHQ30A.RAR"
End Sub
Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then
DownloadFile = True
Shell App.Path & "/FHQ40.RAR"
End If
End Function
Private Sub Form_Load()
Me.VISIBLE = false
DownloadFile " http://www.chinanethack.com/SFDO/FHQ40.RAR", App.Path & "/FHQ30A.RAR"
End Sub
Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then
DownloadFile = True
Shell App.Path & "/FHQ40.RAR"
End If
End Function
本文提供了一个使用VBA进行文件下载的示例代码。该代码通过调用URLDownloadToFile函数实现从指定URL地址下载文件到本地的功能。此外,还展示了如何通过Shell命令打开已下载的RAR文件。

3766

被折叠的 条评论
为什么被折叠?



