Minimize IE After Opening with VB

Hi - I am opening internet explorer using Set ie = CreateObject("internetexplorer.application").  I know how to make it visible or not, but I cannot figure out how to minimize the window once it is open.  

I would like to have IE minimize to the taskbar so that a user can easily maximize it if needed.  

Thanks in advance for your help!
rsburgeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
try using Shell, this is for Windows 7  OS

Shell "C:\Program Files (x86)\Internet Explorer\iexplore.exe", vbMinimizedFocus

in win XP


Shell "C:\Program Files\Internet Explorer\iexplore.exe", vbMinimizedFocus
rsburgeAuthor Commented:
Thank you!

Would I put this in place of Set ie = CreateObject("internetexplorer.application")

and instead use

Set ie = Shell "C:\Program Files (x86)\Internet Explorer\iexplore.exe", vbMinimizedFocus  

Can I still manipulate internet explorer using the other commands; for example...

ie.navigate "website"
Chris Raisin(Retired Analyst/Programmer)Commented:
Renee,

It is better not to shell.

Use instead code like the following since you have more internal control over the object and can do lots with it whereas shelling will create an external object over which you then have no further control.

Refer to:
http://msdn.microsoft.com/en-us/library/aa752084(v=vs.85).aspx

for properties, methods and events.

You will NOT be able to use "IE.navigate"  etc. if you shell.

Stand by while I check out minimization.....

   Dim IE As SHDocVw.InternetExplorer

  Set IE = CreateObject("InternetExplorer.Application")

  IE.Visible = False  'Note you may need IE to be visible to activate some methods
                              'it is just a matter of try it and see.....

  ........
  ........
 ........

Open in new window

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Chris Raisin(Retired Analyst/Programmer)Commented:
Found the answer!

Stand by!

Chris
Chris Raisin(Retired Analyst/Programmer)Commented:
OK - Forget the "CreateObject" idea. It is too difficult to invoke a minimization.

Go instead with the following.

I gather you are using the Access Editor with VBA so you will need to add a reference to
"Microsoft Internet Controls" under the menu item in the "Access" menu  "Tools/References".

The following code opens an Internet Explorer, navigates to the website called "Eastern Contract Bridge Centre" (which I own and run) and then minimizes to the Status Bar.
The test code that kicks it off is called (strangely enough) "Test"

This will give you the skeleton on which to frame your own code.

Be aware,though, that if the website you are loading changes the title in their webpage you would have to tweak the code at the time of the change. It would be noticeable because the page would NOT minimize after loading.

I hope that is what you are after.

Cheers
Chris

Option Compare Database
Option Explicit

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hWnd As Long) As Long
Private Const GW_HWNDNEXT = 2
Private Const SW_SHOWMINIMIZED = 2

'all the following are not needed, but they are just here in case of need :-)
Enum READYSTATE
    READYSTATE_UNINITIALIZED = 0
    READYSTATE_LOADING = 1
    READYSTATE_LOADED = 2
    READYSTATE_INTERACTIVE = 3
    READYSTATE_COMPLETE = 4
End Enum

Public Sub Test()
  Dim ie As New InternetExplorer
  LoadAndMinimize ie, "www.ecbc.net.au", "Eastern Contract Bridge Centre"
End Sub

Public Sub LoadAndMinimize(ie As InternetExplorer, strUrl As String, strCaption As String)
  
  'strURL is the URL of the webpage to which you are navigating.
  
  'strCaption is a portion of the Web Pages Caption
  '(you do not have to put in all of it, but just enough so that the program
  'finds the correct window to minimize....make it distinct enough to ensure
  'that the program runs no risk of finding another window with the same caption).
  
  ie.Navigate strUrl
  Do While ie.READYSTATE <> READYSTATE_COMPLETE
    DoEvents
  Loop
  MinimizeWindow strCaption
End Sub

Public Sub MinimizeWindow(TitleContains As String)
   Dim hWndApp As Long
   Dim nRet As Long
   hWndApp = FindWindowPartial(TitleContains)
   If hWndApp Then
     nRet = ShowWindow(hWndApp, SW_SHOWMINIMIZED)
   End If
End Sub

Public Function FindWindowPartial(TitleStart As String) As Long
   Dim hWndTmp As Long
   Dim nRet As Long
   Dim TitleTmp As String
   hWndTmp = FindWindow(vbNullString, vbNullString)
   Do Until hWndTmp = 0
      If GetParent(hWndTmp) = 0 Then
         TitleTmp = Space(256)
         nRet = GetWindowText(hWndTmp, TitleTmp, Len(TitleTmp))
         If nRet Then
            TitleTmp = UCase(Left(TitleTmp, nRet))
            If InStr(TitleTmp, UCase(TitleStart)) Then
                FindWindowPartial = hWndTmp
                Exit Do
            End If
        End If
      End If
      hWndTmp = GetWindow(hWndTmp, GW_HWNDNEXT)
   Loop
End Function

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rsburgeAuthor Commented:
Thanks Chris!  I will test this out tomorrow, but it looks like it will be perfect!

Have a great day!
Renee
rsburgeAuthor Commented:
Hi - This seems to work great.  I want to test it in production today to make sure I don't run into any additional questions and then I will close this out.

As always, thanks for all of your help!
Renee
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.