Hello Gediminas,
try this:
'-Begin----------------------------------------------------------------- '-Directives---------------------------------------------------------- Option Explicit '-Variables----------------------------------------------------------- Dim application, SapGuiAuto, connection, session, RepName Dim WScr, MyApp, MyItem, FileName '-Main---------------------------------------------------------------- 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(1) End If If IsObject(WScript) Then WScript.ConnectObject session, "on" WScript.ConnectObject application, "on" End If Set WScr = CreateObject("WScript.Shell") If IsObject(WScr) Then RepName = "PROGDELE" FileName = "C:\Schnell\Dummy\" & RepName & ".pdf" session.findById("wnd[0]/tbar[0]/okcd").text = "/nSE38" session.findById("wnd[0]/tbar[0]/btn[0]").press session.findById("wnd[0]/usr/ctxtRS38M-PROGRAMM").text = RepName session.findById("wnd[0]/usr/btnSHOP").press WScript.Sleep 500 WScr.AppActivate "ABAP Editor: Report " & RepName & " anzeigen" WScript.Sleep 2000 session.findById("wnd[0]/usr/cntlEDITOR/shellcont/shell").SetFocus() WScr.SendKeys "+{F5}" 'Customize Shift+F5 to File.ExportPDF WScript.Sleep 250 wscr.SendKeys FileName WScript.Sleep 250 wscr.SendKeys "{ENTER}" WScript.Sleep 1000 Set MyApp = CreateObject("Outlook.Application") If IsObject(MyApp) Then Set MyItem = MyApp.CreateItem(0) With MyItem .To = "mailto:hugo.bambi@fantasie.org" .Subject = "Subject" .ReadReceiptRequested = False .Body = "Here comes the file" .Attachments.Add FileName End With MyItem.Display 'MyItem.Send Set MyItem = Nothing Set MyApp = Nothing End If Set WScr = Nothing End If '-End-------------------------------------------------------------------
This script starts the TAC SE38 and loads the Report PROGDELE. It exports the report as PDF and sends the PDF file via e-mail to hugo.bambi.
All you have to do, to try this script, is to customize your SE38 view, that the shortcut Shift+F5 ist set to File.ExportPDF.
You see, it is possible to save a PDF from SAP and to send it as e-mail attachment . Also you see it is possible to handle SAP dialog windows. And it should be not a great problem to do this steps in loop for more than one document.
Let us know your result.
Cheers
Stefan