cancel
Showing results for 
Search instead for 
Did you mean: 

Passing on parameters to Excel macro from SAP script

Former Member
0 Kudos

Hi All - does anybody know the way to pass on a parameter to an Excel macro from within the SAP script? I have this line:

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

Set xclapp = CreateObject("Excel.Application")

xclapp.ScreenUpdating = False

xclapp.Visible = False

xclapp.DisplayAlerts = False

Set xclwbk = xclapp.Workbooks.Open("S:\Schedules\Excel_Scripts.xls")

xclapp.Run "Excel_Scripts.xls!New_MR_Bklog_No_Op_wp(PrS)"

Set xclwbk = Nothing

xclapp.Quit

set xclapp = Nothing

WScript.Quit

This doesn't work because it thinks the paramaeter is part of the macro name. How would I go about sending the contents of that variable across?

Thanks

Umur

Accepted Solutions (1)

Accepted Solutions (1)

thomas_brutigam2
Active Participant
0 Kudos

Hi Umur,

it should be like this:


Set xcl = createObject("Excel.Application")
set wbk = xcl.Workbooks.open("C:\Mappe1.xls")
xcl.ScreenUpdating = False
xcl.Visible = True
xcl.DisplayAlerts = False
xcl.Run "Modul1.Main", "Hallo Welt"
wbk.close
set wbk = nothing
xcl.quit
set xcl = Nothing

Testetd under winXP and Ofifce 2003

The Sub Main looks like this


Sub Main (ByVal a_Text as String)
       msgbox (a_text)
End Sub

Former Member
0 Kudos

Thomas - this worked well. Thanks for the response.

Best regards.

Umur

Answers (0)