需要帮助在 VB 脚本中最大化 IE 窗口。尝试了几种方法但都无济于事。
Option Explicit
Dim objApp, nIE, oIE, Window
Set objApp = CreateObject("Shell.Application")
Set oIE = Nothing
For Each Window In objApp.Windows
If InStr(Window.Name, "Internet Explorer") Then
Set oIE = Window
End If
Next
If oIE Is Nothing Then
Call NewIE
Else
Call OpenIE
End If
'Internet Explorer is closed.
Sub NewIE()
Set nIE = CreateObject("InternetExplorer.Application")
nIE.Navigate2 "https://www.bbc.com"
nIE.Navigate2 "https://www.microsoft.com/en-us/microsoft-
365/onedrive/online-cloud-storage", 4096
nIE.Visible = True
End Sub
'Internet Explorer is already opened.
Sub OpenIE()
oIE.Navigate2 "https://www.bbc.com", 2048
oIE.Navigate2 "https://www.microsoft.com/en-us/microsoft-
365/onedrive/online-cloud-storage", 4096
oIE.Visible = True
End Sub
答案1
答案2
只需将nIE.FullScreen = True
和添加oIE.FullScreen = True
到您的脚本中:
Option Explicit
Dim objApp, nIE, oIE, Window
Set objApp = CreateObject("Shell.Application")
Set oIE = Nothing
For Each Window In objApp.Windows
If InStr(Window.Name, "Internet Explorer") Then
Set oIE = Window
End If
Next
If oIE Is Nothing Then
Call NewIE
Else
Call OpenIE
End If
'Internet Explorer is closed.
Sub NewIE()
Set nIE = CreateObject("InternetExplorer.Application")
nIE.Navigate2 "https://www.bbc.com"
nIE.Navigate2 "https://www.microsoft.com/en-us/microsoft-365/onedrive/online-cloud-storage", 4096
nIE.Visible = True
nIE.FullScreen = True
End Sub
'Internet Explorer is already opened.
Sub OpenIE()
oIE.Navigate2 "https://www.bbc.com", 2048
oIE.Navigate2 "https://www.microsoft.com/en-us/microsoft-365/onedrive/online-cloud-storage", 4096
oIE.Visible = True
oIE.FullScreen = True
End Sub
请注意,许多网站不再适用于 IE,而且许多现在可以运行的网站在不久的将来可能无法运行。