<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: SAP Script Run from Excel Macro - VF03 in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-script-run-from-excel-macro-vf03/m-p/11889560#M1961384</link>
    <description>&lt;P&gt;You should ask on a WScript forum... (or better, search, because such a question has been probably asked many times...)&lt;/P&gt;</description>
    <pubDate>Sun, 24 Mar 2019 13:42:32 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2019-03-24T13:42:32Z</dc:date>
    <item>
      <title>SAP Script Run from Excel Macro - VF03</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-script-run-from-excel-macro-vf03/m-p/11889559#M1961383</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
  &lt;P&gt;I'm buidling a Macro to automate the download the PDF of an invoice from SAP. I've got it mostly figured out, but I always get stuck on WScript - Object required error.&lt;/P&gt;
  &lt;P&gt;Can someone help me?&lt;/P&gt;
  &lt;P&gt;Here's the code:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;Private Sub CommandButton2_Click()


If Not IsObject(SAPguiAPP) Then


   Set SAPguiAuto = GetObject("SAPGUI")


   Set SAPguiAPP = SAPguiAuto.GetScriptingEngine


End If


If Not IsObject(Connection) Then


   Set Connection = SAPguiAPP.Children(0)


End If


If Not IsObject(SAP_Session) Then


   Set SAP_Session = Connection.Children(0)


End If


If IsObject(WScript) Then


   WScript.ConnectObject SAP_Session, "on"


   WScript.ConnectObject SAPguiAPP, "on"


End If


Set xclapp = GetObject(, "Excel.Application")


    Set xclwbk = xclapp.Workbooks.Open("C:\Users\PS1043272\Desktop\CNPDF.xlsm")


    Set xclsht = xclwbk.Sheets("Sheet1")


For i = 2 To xclapp.ActiveCell.SpecialCells(11).Row


        INVCN = xclsht.Cells(2, 1).Value


SAP_Session.FindById("wnd[0]").maximize


SAP_Session.FindById("wnd[0]/tbar[0]/okcd").Text = "/nvf03"


SAP_Session.FindById("wnd[0]").sendVKey 0


SAP_Session.FindById("wnd[0]/usr/ctxtVBRK-VBELN").Text = INVCN


SAP_Session.FindById("wnd[0]/mbar/menu[0]/menu[11]").Select


SAP_Session.FindById("wnd[1]").sendVKey 37


Set WshShell = CreateObject("WScript.Shell")


WshShell.AppActivate "Print Preview"


SAP_Session.FindById("wnd[0]/tbar[0]/okcd").Text = "pdf!"


SAP_Session.FindById("wnd[0]").sendVKey 0


WScript.Sleep 500


SAP_Session.FindById("wnd[1]/usr/cntlHTML/shellcont/shell").SetFocus


WScript.Sleep 250


WshShell.SendKeys "^+s"

WScript.Sleep 750

WshShell.SendKeys "%n"


WshShell.SendKeys "C:\Users\PS1043272\Desktop\" &amp;amp; CStr(INVCN) &amp;amp; "teste.pdf"


WshShell.SendKeys "%s"


WScript.Sleep 500


Next


End Sub
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;I awlays get stuck on the first WScript.Sleep. anyone knows why?&lt;/P&gt;
  &lt;P&gt;when i run the macro it says "run-time Error 424: Object Required" and when i run the script on SAP I get the error "Object Required: WScript -"&lt;/P&gt;
  &lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sun, 24 Mar 2019 13:16:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-script-run-from-excel-macro-vf03/m-p/11889559#M1961383</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-03-24T13:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: SAP Script Run from Excel Macro - VF03</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-script-run-from-excel-macro-vf03/m-p/11889560#M1961384</link>
      <description>&lt;P&gt;You should ask on a WScript forum... (or better, search, because such a question has been probably asked many times...)&lt;/P&gt;</description>
      <pubDate>Sun, 24 Mar 2019 13:42:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-script-run-from-excel-macro-vf03/m-p/11889560#M1961384</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-03-24T13:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: SAP Script Run from Excel Macro - VF03</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-script-run-from-excel-macro-vf03/m-p/11889561#M1961385</link>
      <description>&lt;P&gt;Hello Pedro,&lt;/P&gt;&lt;P&gt;Did you manage to resolve your problem? Is there any option to automize via macro the VF03 transation?  Kind regards and many thanks,&lt;/P&gt;&lt;P&gt;Natalia&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 13:10:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-script-run-from-excel-macro-vf03/m-p/11889561#M1961385</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-04-02T13:10:57Z</dc:date>
    </item>
  </channel>
</rss>

