Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2878

Re: Scripts to save a PDF copy of a doc from SAP screen to our desktop.

$
0
0

Hi Stefan,

 

I am sure, i am wrongly asking in this thread. But its easy for me to make you understand. I have used the code completely. Thanks for your help!!!. But in my SAP. PDF Preview opened it as separate window as shown below. I guess send keys are different. I used scripting tracker and got control ID which shown in the second screen

 

Screen1.png

screen2.png

 

I am using the below code and i am not able to save the invoice. Could you please explain me where i have to change the code so that my job will get done.

 

Sub sd()

 

 

If Not IsObject(Application1) Then

   Set SapGuiAuto = GetObject("SAPGUI")

   Set Application1 = SapGuiAuto.GetScriptingEngine

End If

If Not IsObject(Connection) Then

   Set Connection = Application1.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 Application1, "on"

End If

 

On Error Resume Next

 

Sheets("Inputs").Select

 

lt = Range("a65000").End(xlUp).Row

 

Range("a6").Select

 

For i = 7 To lt

 

Sheets("Inputs").Select

ActiveCell.Offset(1, 0).Select

 

session.findById("wnd[0]/tbar[0]/okcd").Text = "/nVF03"

session.findById("wnd[0]").sendVKey 0

 

 

CCD = ActiveCell.Value

 

 

session.findById("wnd[0]/usr/ctxtVBRK-VBELN").Text = CCD

session.findById("wnd[0]/usr/txtRV60S-BELNR").SetFocus

session.findById("wnd[0]/usr/txtRV60S-BELNR").caretPosition = 0

session.findById("wnd[0]/mbar/menu[0]/menu[11]").Select

session.findById("wnd[1]/usr/tblSAPLVMSGTABCONTROL").getAbsoluteRow(0).Selected = True

session.findById("wnd[1]/tbar[0]/btn[37]").press

session.findById("wnd[0]/tbar[0]/okcd").Text = "PDF!"

session.findById("wnd[0]").sendVKey 0

 

Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.AppActivate "Print Preview" 'Title of the window

WScript.Sleep 500

 

'Set the focus to the Acrobat control but check the correct ID of the control

session.findById("wnd[1]/usr/cntlHTML/shellcont/shell").SetFocus

WScript.Sleep 250

 

 

WshShell.SendKeys "^+s" 'Open save dialog

WScript.Sleep 750

 

WshShell.SendKeys "%n" 'Activate file name field

WshShell.SendKeys "C:\Users\myname\001.pdf" 'Path and file name

WshShell.SendKeys "%s" 'Save the file

'/app/con[0]/ses[0]/wnd[1]/usr/cntlHTML/shellcont/shell

 

 

session.findById("wnd[1]").Close

 

Next

 

lts:

 

End Sub


Viewing all articles
Browse latest Browse all 2878

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>