Live-Forum - Die aktuellen Beiträge
Datum
Titel
24.04.2024 19:29:30
24.04.2024 18:49:56
Anzeige
Archiv - Navigation
1040to1044
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Internet Explorer minimieren

Internet Explorer minimieren
21.01.2009 13:40:36
Kastner
Hallo zusammen,
ich suche verzweifelt eine Möglichkeit, den Internet Explorer per Makro zu minimieren.
Kurz: Ich möchte eine Datei öffnen, welche auf einem FTP-Server liegt. Die Datei kann man in mehreren Modis (ReadOnly etc..) öffnen. Allerdings erscheint das Fenster hinter dem IExplorer. Daher muss ich Ihn minimieren.
Hab auch schon alles mögliche probiert:
SendKeys "%{Tab}", 1
oder
SendKeys "{%}", True
SendKeys "{space}", True
SendKeys ("n"), True
letzte Variante funzt leider überhaupt nicht, da der Internet Explorer noch arbeitet und daher Alt nicht funktioniert.
Gibt es ein Makro mit welchem ich den InternetExplorer minimieren kann und danach möchte ich per SendKeys nur die Entertaste drücken.
Ich finde aber leider keine Lösung mehr...

7
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Internet Explorer minimieren
Ramses
Hallo
Und was hat das mit EXCEL zu tun ?
Wenn du einen VBA - Code aus EXCEL verwendest, solltest du diesen Online stellen damit Hilfe geboten werden kann.
Alles andere ist ein Ratespiel wo niemand Lust dazu hat
Gruss Rainer
hiermit sollte es gehen.
21.01.2009 15:26:26
Tino
Hallo,
es wird zuerst nach dem Fensterhandel des Internetexplorers gesucht und
wird dieser gefunden wird dieses minimiert.
Viel Spaß damit. Getestet unter Vista und IE7.
Modul Modul1
Option Explicit 
 
Private Declare Function GetDesktopWindow Lib "user32" () As Long 
 
Private Declare Function GetWindowTextLength Lib "user32" _
        Alias "GetWindowTextLengthA" (ByVal hWnd 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 GetWindowLong Lib "user32" Alias _
        "GetWindowLongA" (ByVal hWnd As Long, ByVal wIndx As _
        Long) 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 
 
Const GW_HWNDFIRST = 0 
Const GW_HWNDLAST = 1 
Const GW_HWNDNEXT = 2 
Const GW_HWNDPREV = 3 
Const GW_OWNER = 4 
Const GW_CHILD = 5 
Const GW_MAX = 5 
 
Const iNormal As Long = 1 
Const iMinimized  As Long = 2 
Const iMaximized  As Long = 3 
 
Private Function GetWindowInfo(ByVal hWnd&, sTitel As String) As Long 
  Dim Parent&, Task&, Result&, X&, Style&, Title$ 
   
    'Darstellung des Fensters 
    Style = GetWindowLong(hWnd, GWL_STYLE) 
    Style = Style And (WS_VISIBLE Or WS_BORDER) 
 
    Result = GetWindowTextLength(hWnd) + 1 
    Title = Space$(Result) 
    Result = GetWindowText(hWnd, Title, Result) 
    Title = Left$(Title, Len(Title) - 1) 
     
 
      If Title Like "*" & sTitel & "*" Then 
       GetWindowInfo = hWnd 
       Exit Function 
      End If 
 
 
End Function 
 
'diese Sub minimiert den Internet Explorer 
Sub Minimize_Internet_Explorer() 
Dim hWnd As Long 
Const Nur_Sichtbare As Boolean = True 
 
  hWnd = GetDesktopWindow() 
  hWnd = GetWindow(hWnd, GW_CHILD) 
  GetWindowInfo hWnd, "Internet Explorer" 
 
Do While hWnd <> 0 
    tbuf = String(255, 0) 
    RetVal = GetWindowText(hWnd, tbuf, Len(tbuf)) 
    hWnd = GetWindow(hWnd, GW_HWNDNEXT) 
    
   If GetWindowInfo(hWnd, "Internet Explorer") = hWnd Then 
    ShowWindow hWnd, iMinimized 
   End If 
Loop 
 
End Sub 
 
 


Gruß Tino

Anzeige
Korrektur!
21.01.2009 15:32:09
Tino
Hallo,
habe irgendwie ein bar Deklarierungen gelöscht.
Option Explicit

Private Declare Function GetDesktopWindow Lib "user32" () As Long

Private Declare Function GetWindowTextLength Lib "user32" _
        Alias "GetWindowTextLengthA" (ByVal hWnd 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 GetWindowLong Lib "user32" Alias _
        "GetWindowLongA" (ByVal hWnd As Long, ByVal wIndx As _
        Long) 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

Const GW_HWNDFIRST = 0
Const GW_HWNDLAST = 1
Const GW_HWNDNEXT = 2
Const GW_HWNDPREV = 3
Const GW_OWNER = 4
Const GW_CHILD = 5
Const GW_MAX = 5

Const iNormal As Long = 1
Const iMinimized  As Long = 2
Const iMaximized  As Long = 3
Const GWL_STYLE = (-16)

Private Function GetWindowInfo(ByVal hWnd&, sTitel As String) As Long
  Dim Parent&, Task&, Result&, X&, Style&, Title$
  
    'Darstellung des Fensters 
    Style = GetWindowLong(hWnd, GWL_STYLE)


    Result = GetWindowTextLength(hWnd) + 1
    Title = Space$(Result)
    Result = GetWindowText(hWnd, Title, Result)
    Title = Left$(Title, Len(Title) - 1)
    

      If Title Like "*" & sTitel & "*" Then
       GetWindowInfo = hWnd
       Exit Function
      End If


End Function

'diese Sub minimiert den Internet Explorer 
Sub Minimize_Internet_Explorer()
Dim hWnd As Long, tbuf As String, RetVal As Long
Const Nur_Sichtbare As Boolean = True

  hWnd = GetDesktopWindow()
  hWnd = GetWindow(hWnd, GW_CHILD)
  GetWindowInfo hWnd, "Internet Explorer"

Do While hWnd <> 0
    tbuf = String(255, 0)
    RetVal = GetWindowText(hWnd, tbuf, Len(tbuf))
    hWnd = GetWindow(hWnd, GW_HWNDNEXT)
   
   If GetWindowInfo(hWnd, "Internet Explorer") = hWnd Then
    ShowWindow hWnd, iMinimized
   End If
Loop

End Sub


Anzeige
AW: Korrektur!
21.01.2009 16:42:00
Ramses
Hallo Tino
Nicht schlecht, aber je nachdem wir er dein IE anspricht, reicht ein einfaches ".minimize" oder ".visible = false"
Daher die Frage nach dem verwendeten Code
Gruss Rainer
AW: Korrektur!
21.01.2009 17:05:06
Tino
Hallo,
da hast Du natürlich recht, ich bin davon ausgegangen wenn er Sendkey verwendet,
dass der IE von Hand geöffnet wurde.
Der Code hat noch einiges unnützes Zeugs enthalten, der Stammt aus einem anderen Projekt,
habe ihn nur für diese Aufgabe umgebaut.
Vielleicht bekommen wir ja noch eine Rückmeldung. ;-)
Gruß Tino
AW: Internet Explorer minimieren
23.01.2009 09:12:00
Roland
Guten Morgen zusammen,
erstmal danke für die Antwort, aber leider hilft mir die nicht viel:
anbei wie gefordert der Code:
If CheckBox1.Value = True Then
Seite = "ftp://Datei\test.xls"
Shell ("C:\Program Files\Internet Explorer\Iexplore.exe " & Seite), vbNormalFocus
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 2
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
SendKeys ("Domäne\Benutzername"), 1
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
SendKeys "{Tab}", 1
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
SendKeys ("Passwort"), 1
SendKeys "{Enter}", 2
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
Application.SendKeys "{Tab 3}", 1
SendKeys "{Enter}", 1
SendKeys "%{Tab}", 1
SendKeys "{Enter}", 1
SendKeys "{Enter}", 1
End If
Ich denke, das der Code bestimmt ein bischen umständlich ist, aber meine Kenntnisse reichen dann soweit leider nicht.
Das Problem ist, das der IExplore immer im Vordergrund bleibt und ich allerdings im Hintergrund auf "Read Only" Klicken muss. Da die Datei Schreibgeschützt geöffnet werden muss.
Deshalb muss ich den IExplore minimieren um via SendKeys die Enter-Taste zu senden. Aber leider bekomme ich das nicht hin.
Vielen herzlichen Dank nochmal für die Hilfe
Gruss
Roland
Anzeige
AW: Internet Explorer minimieren
23.01.2009 11:31:00
Tino
Hallo,
wie währe es wen Du Deine Datei erst runterlädst und danach öffnest.
Beispiel:
Option Explicit

Public Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" _
(ByVal pCaller&, ByVal szURL$, ByVal szFileName$, ByVal dwReserved&, ByVal lpfnCB&) As Long
 
 Private Function DownloadFile(ByVal strURL$, ByVal strLocalFilename$) As Boolean
    Dim lngRet As Long
    
    lngRet = URLDownloadToFile(0, strURL, strLocalFilename, 0, 0)
    
    If lngRet = 0 Then DownloadFile = True
 End Function
 
 Sub Download_Datei_aus_Internet()
    Dim strQuellDatei As String
    Dim strZielDatei  As String
    Dim MyDatei As Workbook
    'wo ist die Datei 
    strQuellDatei = "http://www.ms-office-forum.net/forum/showthread.php?t=228695/Beispiel.xls"
    'wo soll die Datei hin 
    strZielDatei = "C:\Testdatei.xls"
    
    'vorhandene Löschen 
    If Dir$(strZielDatei, vbDirectory) <> "" Then
     Kill strZielDatei
    End If
    
 
    If DownloadFile(strQuellDatei, strZielDatei) = False Then
      MsgBox "Download nicht OK"
      Exit Sub
    Else
       'Downlod ok. Datei öffnen 
       Set MyDatei = Workbooks.Open(strZielDatei)
    End If
     
     'hier kannst Du mit MyDatei alles machen was du möchtest. 
     '... 
     '... 
  
 End Sub


Gruß Tino

Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige