on 06-03-2016 5:33 AM
Hi,
I am new in scripting VBA. Need help here. I want to download Invoice copies thru VF03 and save it a desktop or any specific folder.Filw should be saved with Invoice name which will be picked up from range as per loop.
Have generated below loop but unable to save further.
Sub Download_Invoices()
'Initiate SAP
If Not IsObject(SapGuiAuto) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set sapapplication = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = sapapplication.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
'SAP Initiated
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "/nVF03"
session.findById("wnd[0]").sendVKey 0
i = 2
Do While (Cells(i, 1).Value <> "")
session.findById("wnd[0]/usr/ctxtVBRK-VBELN").Text = Cells(i, 1).Value
session.findById("wnd[0]/usr/ctxtVBRK-VBELN").caretPosition = 10
session.findById("wnd[0]/mbar/menu[0]/menu[11]").Select
session.findById("wnd[1]/usr/tblSAPLVMSGTABCONTROL").getAbsoluteRow(0).Selected = False
session.findById("wnd[1]/usr/tblSAPLVMSGTABCONTROL").getAbsoluteRow(1).Selected = True
session.findById("wnd[1]/usr/tblSAPLVMSGTABCONTROL/txtNAST-KSCHL[0,1]").SetFocus
session.findById("wnd[1]/usr/tblSAPLVMSGTABCONTROL/txtNAST-KSCHL[0,1]").caretPosition = 0
session.findById("wnd[1]/tbar[0]/btn[37]").press
session.findById("wnd[0]/tbar[0]/okcd").Text = "PDF!"
session.findById("wnd[0]").sendVKey 0
i = i + 1
Loop
End Sub
hello.
THis is an MS com Dialog. So there VBA Stopps until SAP send Dorne Event back. As this will not Happen during Script rüstige it stucks.
you Need To Handle Control of Save Dialog Outside of Script Running instance To succeed. There arme many Threads in this Forum deskribier what is Root cause and options how To Schiene your requirements.
Regards
holger
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.