Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Macro attached to Menu Command Button

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Macro attached to Menu Command Button

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Macro attached to Menu Command Button

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
macro attached to command button - VBA form Roy Gudgeon[_2_] Excel Discussion (Misc queries) 2 March 16th 10 12:44 PM
Macro attached to New Menu item on toolbar Steven Excel Programming 1 June 5th 08 02:02 AM
adding command button to menu excel-tr Excel Programming 0 March 28th 07 02:01 AM
Macro attached to button runs twice Jozef[_2_] Excel Programming 0 November 4th 04 01:36 PM
MACRO ATTACHED TO A TOOLBAR BUTTON Joyce[_2_] Excel Programming 0 October 9th 03 07:30 PM


All times are GMT +1. The time now is 11:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"