为什么应用程序 windows 在使用 vba 调用后打开后保持最小化?
Why do the application windows remain minimized after opening when called with vba?
当我通过 VBA 打开各种应用程序时,我总是遇到这个问题。 Internet Explorer、Word、Excel等,都打开了,连文档都打开了,但是任务栏上的window仍然是最小化的,必须手动打开。我在几台装有不同版本 Office 的计算机上也遇到了这个问题。 (Windows 10 专业版、Office 2019 专业版和 Office 365),它们都存在同样的问题。有人对此有解决方案吗?坦克
Word 代码(使用 MS-Access VBA):
Sub OpenDoc()
Dim WordApp As Object, WordDoc As String
WordDoc = "C:\Users\Me\Desktop\Document01.docx"
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True
WordApp.Documents.Open (WordDoc)
End Sub
IE 代码:
Sub openIE()
Dim oIE As InternetExplorer
Set oIE = New InternetExplorer
URL = xxx
With oIE
.Visible = True
.Navigate2 URL
.Activate
Do While .readyState <> READYSTATE_COMPLETE
DoEvents
Loop
End With
'or
'With oIE
' .Visible = True
' .Navigate2 URL
' .Activate
'End With
'
' Do While IE.readyState <> READYSTATE_COMPLETE
' DoEvents
' Loop
End Sub
试试这个
Sub OpenDoc()
Dim WordApp As Object, WordDoc As String
WordDoc = "C:\Users\Me\Desktop\Document01.docx"
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True
WordApp.Documents.Open (WordDoc)
WordApp.Activate
End Sub
当我通过 VBA 打开各种应用程序时,我总是遇到这个问题。 Internet Explorer、Word、Excel等,都打开了,连文档都打开了,但是任务栏上的window仍然是最小化的,必须手动打开。我在几台装有不同版本 Office 的计算机上也遇到了这个问题。 (Windows 10 专业版、Office 2019 专业版和 Office 365),它们都存在同样的问题。有人对此有解决方案吗?坦克
Word 代码(使用 MS-Access VBA):
Sub OpenDoc()
Dim WordApp As Object, WordDoc As String
WordDoc = "C:\Users\Me\Desktop\Document01.docx"
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True
WordApp.Documents.Open (WordDoc)
End Sub
IE 代码:
Sub openIE()
Dim oIE As InternetExplorer
Set oIE = New InternetExplorer
URL = xxx
With oIE
.Visible = True
.Navigate2 URL
.Activate
Do While .readyState <> READYSTATE_COMPLETE
DoEvents
Loop
End With
'or
'With oIE
' .Visible = True
' .Navigate2 URL
' .Activate
'End With
'
' Do While IE.readyState <> READYSTATE_COMPLETE
' DoEvents
' Loop
End Sub
试试这个
Sub OpenDoc()
Dim WordApp As Object, WordDoc As String
WordDoc = "C:\Users\Me\Desktop\Document01.docx"
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True
WordApp.Documents.Open (WordDoc)
WordApp.Activate
End Sub