
Originally Posted by
Dave
Maybe it's just a syntax thing. I assume that you have opened the XL wb and that the macro that U want to run exists... I think that the macro also has to be located in a module and be publicly declared as well. Providing these conditions are met the syntax should be...
Application.Run "YourWbName.xlsm!YourSubName"
HTH. Dave
Yes, the target workbook is opened at the beginning of the Sub in Outlook.
'declare mail itemDim Item As MailItem
'declare excel
Dim xlApp As Excel.Application
'declare workbook
Dim xlWB As Excel.Workbook
'declare worksheet
Dim xlSheet As Excel.Worksheet
'Determine path of the destination
Const strPath As String = "C:\TEST.xlsm" ' workbook path and name
'If nothing selected
If Application.ActiveExplorer.Selection.Count = 0 Then
'MsgBox "No Items selected! Dingus, pick an email!!!", vbCritical, "Error"
Exit Sub
End If
On Error Resume Next
'Set the declaration
Set xlApp = GetObject(, "Excel.Application")
If Err <> 0 Then
Application.StatusBar = "Please wait while Excel source is opened ... "
'Create the Excel object itself.
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
'Initiate in the computing environment
bXStarted = True
End If
On Error GoTo 0
'Open the workbook to input the data
Set xlWB = xlApp.Workbooks.Open(strPath)
On Error GoTo ErrClose
'Elect a sheet
Set xlSheet = xlWB.Sheets("Renewals List")
I'm passing vars and macro execution perfectly fine up to the point of activating a Macro with a message box in it. Simply using "Activate ___.xlsm" is not good enough for my needs. I need to set the Windows Environment focus on the XL wb. I'll take a look and see if the XL wb receiving macro is declared as public or not... The receiving macro is declared as Public.
I'm receiving the passed vars just fine. I just need it to activate the workbook like a User clicked on it.
Apologies if I'm confusing LOL. I'm still new to this vernacular.
If you need some code to review lemme know.