我做了一个简单的VBA代码,去一个链接,并下载一个Excel文件,链接是一个中间的HTML页面,然后下载文件,我只需要访问,但现在我需要保存它。我是一个noob在VBA,有人能帮助我吗?
Private pWebAddress As String
Public Declare PtrSafe Function ShellExecute _
Lib "shell32.dll" _
Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Public Sub NewShell(cmdLine As String, lngWindowHndl As Long)
ShellExecute lngWindowHndl, "open", cmdLine, "", "", 1
End Sub
Public Sub WebPage()
Let pWebAddress = "https://imea.com.br/imea-site/arquivo-externo?categoria=relatorio-de-mercado&arquivo=cup-milho&numeropublicacao=4"
Call NewShell(pWebAddress, 3)
我已经研究了很多,但是我见过的都没有帮助。
1条答案
按热度按时间x759pob21#
此网址:
https://imea.com.br/imea-site/arquivo-externo?categoria=relatorio-de-mercado&arquivo=cup-milho&numeropublicacao=4
会指向一个包含以下javascript的页面,该javascript构建了最终的URL:
最终URL为:
https://publicacoes.imea.com.br/relatorio-de-mercado/cup-milho/4
这样就可以直接在Excel中打开Excel文件:
您可以将该js转换为VBA,以创建一个函数,将第一个URL转换为第二个URL。