Link to home
Start Free TrialLog in
Avatar of datastarstar
datastarstar

asked on

How to return VBA function value to VBScript

This will work, where Report is an Excel macro (subroutine) and I pass 2 parameters to it:
  xlApp.Run "Report", CStr(StartCount), CStr(EndCount)

But if Report is a function, and I want it to return a value to the VBScript, I can't get it to work. Have tried variations of this:
ReturnValue =  xlApp.Run "Report", CStr(StartCount), CStr(EndCount)

I get an "expected end of statement" error right before "Report"

???
Avatar of datastarstar
datastarstar

ASKER

Also have this and Dim'd all the vars

  Set xlApp = CreateObject("Excel.Application")      
  xlApp.DisplayAlerts = False
  Set xlBook = xlApp.Workbooks.Open("h:\temp\testbook1.xlsm", 0, True)
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That was easy -- ran without error. I thought I tried every combination of quotes, parentheses, etc.

Thank you!
Great, glad it was that simple.

~bp