1
我是新的宏,可以真正使用一些帮助。下面的代码来自Excel,用于访问网页,搜索超链接并下载PDF文件并将其保存在桌面上。展望VBA代码
我需要修改它的展望:
- 因此,它检测到发件人地址,即[email protected]
- 检测在电子邮件和网页上的超链接来检测按钮“导出详细信息“并按下它
- 然后在下一页按下”导出“按钮并在桌面上保存CVS文件:”C:\ Users \ mlad1406 \ Desktop \ Test“。
我知道寻求帮助有很多,但我不知道如何前进。任何人都可以帮我调整这个代码吗?
谢谢!
Sub DownPDF()
' This macro downloads the pdf file from webpage
' Need to download MSXML2 and MSHTML parsers and install
Dim sUrl As String
Dim xHttp As MSXML2.XMLHTTP
Dim hDoc As MSHTML.HTMLDocument
Dim hAnchor As MSHTML.HTMLAnchorElement
Dim Ret As Long
Dim sPath As String
Dim i As Long
sPath = "C:\Users\mlad1406\Desktop\Test"
sUrl = "https://copernicus.my.salesforce.com/00O20000006WD95"
'Get the directory listing
Set xHttp = New MSXML2.XMLHTTP
xHttp.Open "GET", sUrl
xHttp.Send
'Wait for the page to load
Do Until xHttp.readyState = 4
DoEvents
Loop
'Put the page in an HTML document
Set hDoc = New MSHTML.HTMLDocument
hDoc.Body.innerHTML = xHttp.responseText
'Loop through the hyperlinks on the directory listing
For i = 0 To hDoc.getElementsByTagName("a").Length - 1
Set hAnchor = hDoc.getElementsByTagName("a").Item(i)
'test the pathname to see if it matches your pattern
If hAnchor.PathName Like "Ordin-*.2013.pdf" Then
Ret = UrlDownloadToFile(0, sUrl & hAnchor.PathName, sPath, 0, 0)
If Ret = 0 Then
Debug.Print sUrl & hAnchor.PathName & " downloaded to " & sPath
Else
Debug.Print sUrl & hAnchor.PathName & " not downloaded"
End If
End If
Next i
End Sub
所以你没有关于你想要工作的事情,好吧。但是**你想要检测发件人邮件**?按一个按钮,你的意思是打开超链接? – R3uK
嗨,我想在邮件地址列出的FROM:字段中检测它。关于第二个问题:电子邮件有一个超链接需要检测和按下,这将打开一个网页,并从那里到处都是按钮。 – maximladus
好的,您可以使用我在“oMailItem.SenderEmailAddress”回答中给出的代码,并查找您的链接到主体中。然后,您可能需要使用HTML文档来查找您的按钮及其各自的链接。 – R3uK