ExcelKid_10
Board Regular
- Joined
- Mar 17, 2004
- Messages
- 87
Hello-
I have a VBA Routine where I open workbook and run some code in the newly opened workbook that requires two input parameters...I've been trying to pass them ByVal however the debugger now does not recognize the Call to the procedure if I include the variables...anybody have any ideas on how I remedy this?
Here is my code:
Function OpenExcelPerfAttributionDataFile()
Dim xlApp As Object
Dim xlWb As Object
Dim xlWS As Worksheet
Dim strSheet, strFileName As String
Dim strBegDate, strEndDate, xDate As String
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
strEndDate = DMax("[tblDates]![Report_Date]", "tblDates")
xDate = DateSerial(Year(strEndDate), Month(strEndDate) - 1, Day(strEndDate))
strBegDate = Format(xDate, "MM/DD/YYYY")
strFileName = "PerformTotalReturnLoader.xls"
sFile = "\\faffsprd\fs31_fite$\Quant\Reporting Database And Directions\" & strFileName
Set xlWb = xlApp.Workbooks.Open(sFile, True)
'*****Code crashes on this line....
sMacro = "UpdatePerformanceLoader(" & strBegDate & "," & strEndDate & ")"
'
xlApp.Run sMacro
'xlWb.Close (True) '<saves it
xlApp.Quit
Set xlWS = Nothing
Set xlWb = Nothing
Set xlApp = Nothing
End Function
Thanks!
EK
I have a VBA Routine where I open workbook and run some code in the newly opened workbook that requires two input parameters...I've been trying to pass them ByVal however the debugger now does not recognize the Call to the procedure if I include the variables...anybody have any ideas on how I remedy this?
Here is my code:
Function OpenExcelPerfAttributionDataFile()
Dim xlApp As Object
Dim xlWb As Object
Dim xlWS As Worksheet
Dim strSheet, strFileName As String
Dim strBegDate, strEndDate, xDate As String
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
strEndDate = DMax("[tblDates]![Report_Date]", "tblDates")
xDate = DateSerial(Year(strEndDate), Month(strEndDate) - 1, Day(strEndDate))
strBegDate = Format(xDate, "MM/DD/YYYY")
strFileName = "PerformTotalReturnLoader.xls"
sFile = "\\faffsprd\fs31_fite$\Quant\Reporting Database And Directions\" & strFileName
Set xlWb = xlApp.Workbooks.Open(sFile, True)
'*****Code crashes on this line....
sMacro = "UpdatePerformanceLoader(" & strBegDate & "," & strEndDate & ")"
'
xlApp.Run sMacro
'xlWb.Close (True) '<saves it
xlApp.Quit
Set xlWS = Nothing
Set xlWb = Nothing
Set xlApp = Nothing
End Function
Thanks!
EK