我正在尝试使用 VBA 将网页下载为 pdf。我已经尝试了以下方法,它提示我选择要下载的文件夹和文件名。
有什么方法可以让我事先选择文件夹并自动保存网页而无需任何提示/对话框?
Sub printpdf()
URL = "https://www.londonstockexchange.com/news-article/CTEC/q1-trading-update/14956551"
Set IE = CreateObject("InternetExplorer.Application")
IE.navigate (URL)
IE.StatusBar = False
IE.Toolbar = True
IE.Visible = True
IE.resizable = True
IE.AddressBar = False
TimeOutWebQuery = 5
TimeOutTime = DateAdd("s", TimeOutWebQuery, Now)
Do Until IE.readyState = 4
DoEvents
If Now > TimeOutTime Then
IE.stop
GoTo ErrorTimeOut
End If
Loop
IE.ExecWB 6, 2
Application.Wait (Now + TimeValue("0:00:03"))
ErrorTimeOut:
Set IE = Nothing
End Sub