I open a Excel workbook using this code from within OUTLOOK VBA:
'~~> BEGINNING OF EXCEL CODE <~~
Dim xlApp As Excel.Application
Dim sourceWB As Excel.Workbook
Dim sourceWS As Excel.Worksheet
Set xlApp = New Excel.Application
With xlApp
.Visible = True
.EnableEvents = True
.UserControl = False
.DisplayAlerts = False
.AskToUpdateLinks = False
End With
strFile = scPATH & "Seattle ScoreCard " & Format(prevSCdate, "mm") & "." & Format(prevSCdate, "dd") & "." & Format(prevSCdate, "yy") & ".xlsm"
Set sourceWB = xlApp.Workbooks.Open(strFile, , False, , , , , , , True)
Set sourceWS = xlApp.sourceWB.Worksheets(Chr(34) & "Week " & Format(prevSCdate, "ww") & " " & Format(prevSCdate, "mm") & "." & Format(prevSCdate, "dd") & "." & Format(prevSCdate, "yy") & Chr(34))
'~~> CANT GET THIS TO RUN ONCE EXCEL OPENS <~~
sourceWS.Copy Before:=Sheets(2)
'~~>
...
It opens the correct file and everything, but once it opens it does not execute the sourceWS.Copy line. I have verified that that command works by using executing it directly from VBA in the Excel file. I also have the Excel library activated.
Any help? The results are as if that last line were non existent. It opens the file and then nothing happens.