cancel
Showing results for 
Search instead for 
Did you mean: 

export spread sheet directory path chaging while using in macro

arun231
Discoverer
0 Kudos

Hi,

Requirement is to extract data in excel from Z**** t-code and using it for another requirement. While doing the script recording i am using the desktop path to save the file.

But while running the same script through macro, the saving file directory is changed desktop to below path and getting the below error message.

"windows cannot find 'c:\program files\sap\frontend\sapgui\***.xlsx'. make sure you typed the name correctly and then try again".

Please find the my macro code,

Sub Test()
If Not IsObject(Application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set Sap_Applic = 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
If Not IsObject(Sap_Applic) Then
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "ZSD_PROYBO"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[1]/btn[17]").press
session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").currentCellRow = 1
session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").selectedRows = "1"
session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").doubleClickCurrentCell
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/mbar/menu[0]/menu[3]/menu[1]").Select
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/usr/ctxtDY_FILENAME").Text = "ZSD_PROYBO.XLSX"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").caretPosition = 10
session.findById("wnd[1]/tbar[0]/btn[0]").press
End Sub

Accepted Solutions (0)

Answers (0)