Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I assigned a macro to a Menu Command Button in File1 that opens another file
(File2) and then the File1 macro continues and calls a macro in File2 with Application.Run "..." and then after the macro in File2 has run the last line of code in the macro of File1 is to close File1, Windows("File1.xls").Close(0). But I get an "Appliation Defined Error!" Note: I dont want to go directly to File2 from the Command Button. I want to use File1's macro assigned to the Command Button. How do I do this and not get the error? Thank you, Steven |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi
you don't. file1 macro is the master macro that call the other macro in file 2. the master macro ends when it hits it's end sub not the end sub in macro 2 in file 2. so you are trying to close a file that still has a macro running. opps. error. sorry no way around that. macro 1 must complete before closeing. Regards FSt1 "Steven" wrote: I assigned a macro to a Menu Command Button in File1 that opens another file (File2) and then the File1 macro continues and calls a macro in File2 with Application.Run "..." and then after the macro in File2 has run the last line of code in the macro of File1 is to close File1, Windows("File1.xls").Close(0). But I get an "Appliation Defined Error!" Note: I dont want to go directly to File2 from the Command Button. I want to use File1's macro assigned to the Command Button. How do I do this and not get the error? Thank you, Steven |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you for the response. It is unusual to me. If it is a code running in
an already opened file and I assign a macro to a rectangle object for example it works fine to run the code and close the file, but if it is assigned directly from a command button on the menu then it errors. Thanks, Steven "FSt1" wrote: hi you don't. file1 macro is the master macro that call the other macro in file 2. the master macro ends when it hits it's end sub not the end sub in macro 2 in file 2. so you are trying to close a file that still has a macro running. opps. error. sorry no way around that. macro 1 must complete before closeing. Regards FSt1 "Steven" wrote: I assigned a macro to a Menu Command Button in File1 that opens another file (File2) and then the File1 macro continues and calls a macro in File2 with Application.Run "..." and then after the macro in File2 has run the last line of code in the macro of File1 is to close File1, Windows("File1.xls").Close(0). But I get an "Appliation Defined Error!" Note: I dont want to go directly to File2 from the Command Button. I want to use File1's macro assigned to the Command Button. How do I do this and not get the error? Thank you, Steven |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
macro attached to command button - VBA form | Excel Discussion (Misc queries) | |||
Macro attached to New Menu item on toolbar | Excel Programming | |||
adding command button to menu | Excel Programming | |||
Macro attached to button runs twice | Excel Programming | |||
MACRO ATTACHED TO A TOOLBAR BUTTON | Excel Programming |