首页 > 解决方案 > 将网页打印为pdf没有对话框Excel VBA

问题描述

我正在尝试使用 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

标签: vbapdfweb-scraping

解决方案


推荐阅读