Ich habe lange nach einer Lösung gesucht - leider aber nichts finden können.
Ich möchte, dass sich Hyperlinks in edinem neuen Tab öffnen und nicht in einer neuen IE-Instanz.
Dann möchte ich Daten aus Excel an bestimmte Felder in diesem neuen IE-Tab übergeben.
Hier mein Code, denn ich jetzt verwende:
Sub Atoss()
Dim objShell As Object, IEDoc As Object
Dim IEApp As Object, win As Object
Dim IEDocument As Object
Dim Adresse As String
Dim Benutzer As String
Dim Kennwort As String
Dim link As Object
Adresse = ActiveCell.Offset(0, 3)
Benutzer = ActiveCell.Offset(0, 7)
Kennwort = ActiveCell.Offset(0, 9)
Set objShell = CreateObject("Shell.Application")
For Each win In objShell.Windows
Next
Set IEApp = CreateObject("InternetExplorer.Application")
IEApp.Visible = True
IEApp.navigate Adresse
Do: Loop Until IEApp.Busy = False
Set IEDoc = IEApp.document
Do: Loop Until IEDoc.readyState = "complete"
Application.Wait TimeSerial(Hour(Now()), _
Minute(Now()), Second(Now()) + 2)
Set IEDocument = IEApp.document
IEDocument.getElementById("logonid").Value = Benutzer
IEDocument.getElementById("password").Value = Kennwort
Dim WshShell As Object
Set WshShell = CreateObject("WScript.Shell")
Application.Wait TimeSerial(Hour(Now()), _
Minute(Now()), Second(Now()) + 1)
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{ENTER}"
Do: Loop Until IEDoc.readyState = "complete"
Application.Wait TimeSerial(Hour(Now()), _
Minute(Now()), Second(Now()) + 1)
IEDocument.getElementById("zemsdabsemp-cnt").Click
Set IEApp = Nothing
Set objShell = Nothing
End Sub
Der Code öffnet aber den Internetexplorer neu und nicht die Seite in einem neuen Tab.Ich habe dann versucht, es so zu lösen:
Sub Atoss_neu()
Dim objShell As Object, IEDoc As Object
Dim IEApp As Object, win As Object
Dim IEDocument As Object
Dim Adresse As String
Dim Benutzer As String
Dim Kennwort As String
Dim link As Object
Adresse = ActiveCell.Offset(0, 3)
Benutzer = ActiveCell.Offset(0, 7)
Kennwort = ActiveCell.Offset(0, 9)
Set objShell = CreateObject("Shell.Application")
For Each win In objShell.Windows
If InStr(1, UCase(win.FullName), "IEXPLORE") > 0 Then
Set IEApp = win
IEApp.Navigate2 Adresse, 2048
Exit For
End If
Next
If IEApp Is Nothing Then
Set IEApp = CreateObject("InternetExplorer.Application")
IEApp.Visible = True
IEApp.navigate Adresse
End If
Application.Wait TimeSerial(Hour(Now()), _
Minute(Now()), Second(Now()) + 2)
Set IEDocument = IEApp.document
IEDocument.getElementById("logonid").Value = Benutzer
IEDocument.getElementById("password").Value = Kennwort
Dim WshShell As Object
Set WshShell = CreateObject("WScript.Shell")
Application.Wait TimeSerial(Hour(Now()), _
Minute(Now()), Second(Now()) + 1)
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{ENTER}"
Do: Loop Until IEDoc.readyState = "complete"
Application.Wait TimeSerial(Hour(Now()), _
Minute(Now()), Second(Now()) + 1)
IEDocument.getElementById("zemsdabsemp-cnt").Click
Set IEApp = Nothing
Set objShell = Nothin
End Sub
Damit öffnet er zwar die Url in einem neuen Tab, jedoch kommt in der ZeileIEDocument.getElementById("logonid").Value = Benutzer
die Meldung "Laufzeitfehler 91 - Objektvariable oder With-Blockvariable nicht festgelegt".
Kann mir evtl. jemand helfen?
Gruß und Danke!
Werner