I've set up a macro to run as a custom menu item on a custom menu in excel. It opens a workbook & performs various functions, saves the info & then closes the workbooks (including the macro workbook).
I also set up this macro to autostart when the workbook is opened, which is how I get it to run from the desktop (it opens excel, the workbook, etc.) This was accomplished by using:
Private Sub Workbook_Open()
My Macro
End Sub
From the desktop it runs fine. However, running it from the menu in Excel causes it a real problem - it runs, closes, & tries to run again, but the macro file is closed & I get an error. Is there a conditional statement I should put in the Private Sub that will recognize that it's being run from the menu as opposed to the desk top, so that it will terminate the autoopen macro prior to the MyMacro statement?
I also set up this macro to autostart when the workbook is opened, which is how I get it to run from the desktop (it opens excel, the workbook, etc.) This was accomplished by using:
Private Sub Workbook_Open()
My Macro
End Sub
From the desktop it runs fine. However, running it from the menu in Excel causes it a real problem - it runs, closes, & tries to run again, but the macro file is closed & I get an error. Is there a conditional statement I should put in the Private Sub that will recognize that it's being run from the menu as opposed to the desk top, so that it will terminate the autoopen macro prior to the MyMacro statement?