How can I maximize an IE window created by VBA with SHDocVw.InternetExplorer command?

爱⌒轻易说出口 提交于 2019-12-06 04:30:37

For Internet Control, there's no inherent Window property. You need to use WinAPI.

This code will work :

'/ Win API declaration
Private Declare Function ShowWindow Lib "user32" _
         (ByVal hwnd As Long, ByVal nCmdSHow As Long) As Long
        Const SW_SHOWMAXIMIZED = 3

Sub wpieautologin()

Dim ie As SHDocVw.InternetExplorer

Dim NOME_EMPRESA, CNPJ, CPF, COD_ACESSO As String
Dim Lookup_Range As Range

Set ie = New SHDocVw.InternetExplorer
ie.Visible = False

ie.Navigate "http://www8.receita.fazenda.gov.br/simplesnacional/controleacesso/autentica.aspx?id=6"



'// rest of your code....


'/ Win API to maximize it.
'/ Visible prop not required anymore
ShowWindow ie.hwnd, SW_SHOWMAXIMIZED
End Sub

Check other window state at : http://www.techrepublic.com/blog/10-things/10-plus-of-my-favorite-windows-api-functions-to-use-in-office-applications/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!