Wscript.sleep geht leider nicht. Der Befehl wird zwar nicht als falsch ausgegeben aber er wird anscheinend eifnach ignoriert.
If Not IsObject(application) Then
   Set SapGuiAuto  = GetObject("SAPGUI")
   Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
   Set connection = application.Children(0)
End If
If Not IsObject(session) Then
   Set session    = connection.Children(0)
End If
If IsObject(WScript) Then
   WScript.ConnectObject session,     "on"
   WScript.ConnectObject application, "on"
End If
dim myIcon
dim myIcon2
dim Zeile
dim Zeile2
Dim Zeile3
Dim ZeileExcel
dim Auftrag
dim x
dim y
Dim AuftragExcel
Zeile =2
Zeile2=2
ZeileExcel=2
Dim ExcelApp, ExcelWB, ExcelWS
	set ExcelApp=createobject("Excel.Application")
	ExcelApp.visible=true
	set ExcelWB=ExcelApp.Workbooks.Open("V:\Users\11398375\Contacts\Auftraege.xlsm")
	set ExcelWS=ExcelWB.Worksheets("WET")
for ZeileExcel = 3 to 100'ExcelApp.Cells(1,8)
	AuftragExcel = ExcelApp.Cells(ZeileExcel,6)
	session.findById("wnd[0]/usr/ctxtAUFNR-LOW").text = AuftragExcel
	session.findById("wnd[0]/tbar[1]/btn[8]").press
	
	session.findById("wnd[0]/usr").verticalScrollbar.position = 100
	session.findById("wnd[0]").maximize
	
	
	yx = left(session.findById("wnd[0]/usr/lbl[2,7]").text,5) '<---- Vor dem Befehl soll gewartet werden. Damit der PC die Zeit hat sich die Daten vom Server zu holen. 
	
	
		i = 8
		on error resume next
		do 
		myIcon =  session.findById("wnd[0]/usr/lbl[3," & cstr(i) & "]").IconName
		if err.number <> 0 then exit do
		'msgbox myIcon & "   Zeilenummer " & i
		i = i + 1
		loop
		on error goto 0
		'msgbox "letzte Ampel (" & myIcon & ") befindet sich in der Zeilenummer: " & cstr(i+1)  'Ausgabe zum Prüfen ob es klappt
		myIcon2 = session.findById("wnd[0]/usr/lbl[3," & cstr(i+1) & "]").IconName
		if myIcon2 = "S_TL_R" then
			y = 7
			x = left(session.findById("wnd[0]/usr/lbl[24," & Y & "]").text, 2)
			If x = "22" then
				Auftrag= session.findById("wnd[0]/usr/lbl[24," & Y & "]").text
				ExcelApp.Cells(Zeile,1).Value = Auftrag
			else
				y = y +1
				x = left(session.findById("wnd[0]/usr/lbl[24," & Y & "]").text, 2)
				If x = "22" then
					Auftrag= session.findById("wnd[0]/usr/lbl[24," & Y & "]").text
					ExcelApp.Cells(Zeile,1).Value = Auftrag
				else
					y = y +1
					x = left(session.findById("wnd[0]/usr/lbl[24," & Y & "]").text, 2)
					If x = "22" then
						x = left(session.findById("wnd[0]/usr/lbl[24," & Y & "]").text, 2)
						ExcelApp.Cells(Zeile,1).Value = Auftrag
					end if
				end if
			end if
			
			
			'msgbox x & "  zeile " & y 'nur zum testen
			Zeile = Zeile +1
		end if
		if myIcon2 = "S_TL_G" then
			y = 7
			x = left(session.findById("wnd[0]/usr/lbl[24," & Y & "]").text, 2)
			If x = "22" then
				Auftrag= session.findById("wnd[0]/usr/lbl[24," & Y & "]").text
				ExcelApp.Cells(Zeile2,2).Value = Auftrag
			else
				y = y +1
				x = left(session.findById("wnd[0]/usr/lbl[24," & Y & "]").text, 2)
				If x = "22" then
					Auftrag= session.findById("wnd[0]/usr/lbl[24," & Y & "]").text
					ExcelApp.Cells(Zeile2,2).Value = Auftrag
				else
					y = y +1
					x = left(session.findById("wnd[0]/usr/lbl[24," & Y & "]").text, 2)
					If x = "22" then
						x = left(session.findById("wnd[0]/usr/lbl[24," & Y & "]").text, 2)
						ExcelApp.Cells(Zeile2,2).Value = Auftrag
					end if
				end if
			end if
			
			
			'msgbox x & "  zeile " & y 'nur zum testen
			Zeile2 = Zeile2 +1
		end if
		session.findById("wnd[0]/tbar[0]/btn[15]").press
	
next
Noch zur Info: Mein Code sieht zwar schlimm aus, aber er funktioniert sonst absolut Problemlos und zügig 🙂 Bin absolut kein Profi in dem was ich hier mache. Bitte steinige mich nicht.