Comment puis-je maximiser une window IE créée par VBA avec la command SHDocVw.InternetExplorer?

Comme le dit le titre, j'essaie de maximiser une window Internet Explorer qui a été créée en utilisant la command suivante:

Set ie = New SHDocVw.InternetExplorer 

Au lieu de:

 Set ie = CreateObject("InternetExplorer.Application") 

Voici le code complet:

 Sub wpieautologin() Dim ie As SHDocVw.InternetExplorer Dim NOME_EMPRESA, CNPJ, CPF, COD_ACESSO As Ssortingng 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" NOME_EMPRESA = Range("B8").Value Set Lookup_Range = Range("B12:E500") CNPJ = Application.WorksheetFunction.VLookup(NOME_EMPRESA, Lookup_Range, 2, False) CPF = Application.WorksheetFunction.VLookup(NOME_EMPRESA, Lookup_Range, 3, False) COD_ACESSO = Application.WorksheetFunction.VLookup(NOME_EMPRESA, Lookup_Range, 4, False) Do Loop Until ie.readystate = 4 Call ie.Document.GetElementByID("ctl00_ContentPlaceHolder_txtCNPJ").SetAtsortingbute("value", CNPJ) Call ie.Document.GetElementByID("ctl00_ContentPlaceHolder_txtCPFResponsavel").SetAtsortingbute("value", CPF) Call ie.Document.GetElementByID("ctl00_ContentPlaceHolder_txtCodigoAcesso").SetAtsortingbute("value", COD_ACESSO) ie.Visible = True >'What should I write here to maximize my IE Window? >'Already sortinged a few solutions, but they works only when the IE is created by the command >'Set ie = CreateObject("InternetExplorer.Application") #INSERT COMMAND TO MAXIMIZE WINDOW HERE End Sub 

Alors, comment puis-je réaliser cela?

Pour le contrôle Internet, il n'y a pas de propriété Window inhérente. Vous devez utiliser WinAPI.

Ce code fonctionnera:

 '/ 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 Ssortingng 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 

Vérifiez l'autre état de la window à: http://www.techrepublic.com/blog/10-things/10-plus-of-my-favorite-windows-api-functions-to-use-in-office-applications/