【问题标题】:As soon pdf file is open in Internet Explorer, the printmask should be open在 Internet Explorer 中打开 pdf 文件后,应该打开打印掩码
【发布时间】:2019-01-08 22:14:04
【问题描述】:
场景:
- 打开 Internet Explorer
- 转到特定网页
- 输入一些必需的信息
- 点击按钮信息将被传输
- 之后,将创建一个 pdf 文件并在浏览器中显示(IE 新
制表符)
现在我需要的是,自动打印此 pdf 文件或打开打印掩码,然后按 enter。
我希望使用宏来执行此操作,但不知道如何在 IE 中执行此操作。
另一个想法是用 C# 编写一个服务来监听一些事件....
有人有想法吗?
谢谢!
【问题讨论】:
标签:
c#
pdf
internet-explorer
macros
【解决方案1】:
您可以尝试参考下面的代码示例并开始使用 VBA 学习 IE 自动化。这对您来说是一个很好的开始示例。如果您遇到任何问题,请在您身边尝试并告诉我们。
Sub Automate_IE_Load_Page()
'This will load a webpage in IE
Dim i As Long
Dim URL As String
Dim IE As Object
Dim objElement As Object
Dim objCollection As Object
'Create InternetExplorer Object
Set IE = CreateObject("InternetExplorer.Application")
'Set IE.Visible = True to make IE visible, or False for IE to run in the background
IE.Visible = True
'Define URL
URL = "https://www.Microsoft.com"
'Navigate to URL
IE.Navigate URL
' Statusbar let's user know website is loading
Application.StatusBar = URL & " is loading. Please wait..."
' Wait while IE loading...
'IE ReadyState = 4 signifies the webpage has loaded (the first loop is set to avoid inadvertently skipping over the second loop)
Do While IE.ReadyState = 4: DoEvents: Loop 'Do While
Do Until IE.ReadyState = 4: DoEvents: Loop 'Do Until
'Webpage Loaded
Application.StatusBar = URL & " Loaded"
'Unload IE
Set IE = Nothing
Set objElement = Nothing
Set objCollection = Nothing
End Sub
参考:
Automate Internet Explorer (IE) Using VBA
要从 IE 打印,您可以参考下面链接中的答案。
Print an IE Web Page