[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Minimize IE After Opening with VB

Posted on 2012-03-23
7
Medium Priority
?
2,708 Views
Last Modified: 2012-03-27
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!
0
Comment
Question by:rsburge
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37759799
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
0
 

Author Comment

by:rsburge
ID: 37759834
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"
0
 
LVL 13

Expert Comment

by:Chris Raisin
ID: 37760433
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

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 13

Expert Comment

by:Chris Raisin
ID: 37760504
Found the answer!

Stand by!

Chris
0
 
LVL 13

Accepted Solution

by:
Chris Raisin earned 2000 total points
ID: 37760625
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

0
 

Author Comment

by:rsburge
ID: 37760913
Thanks Chris!  I will test this out tomorrow, but it looks like it will be perfect!

Have a great day!
Renee
0
 

Author Comment

by:rsburge
ID: 37765873
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
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question