![]() |
Activate second macro only after the first macro is run
Hello Friends,
Thanks to everybody for your continued help and guidance. I tried to find this particular problem in the group but could not find it so far. It would be great if somebody could please help me with this. I have made a new menu tool bar with two macros - the first macro draw graphs in a new sheet and the second macro prints those graphs. I want that the print_graphs macro to get activated only after the user has first clicked on draw_graphs and the graphs are generated successfully. What is currently happening is both these macros are activated simultaneously at all times. I am really stuck with this and I would be highly obliged if somebody from the group could please help me with this. Thanks, and I look forward to hearing from somebody soon. Best regards, Ruchir |
Activate second macro only after the first macro is run
Try to write to the and of first code , the Call procedure :
Call (name of your second macro) End Sub Maybe this help |
Activate second macro only after the first macro is run
Thanks for the prompt reply! I thought of doing that. However, if we
do that, the print_graphs macro will always run. I have to leave it to the user whether he wants to run the print_graphs macro or not. Here is what I am currently doing: Application.CommandBars("Worksheet Menu Bar") Set cbcCutomMenu = _ cbMainMenuBar.Controls.Add(Type:=msoControlPopup) cbcCutomMenu.Caption = "Run &Macro" With cbcCutomMenu.Controls.Add(Type:=msoControlButton) .Caption = "Draw Graphs" .FaceId = 418 .OnAction = "Draw_Graphs" End With With cbcCutomMenu.Controls.Add(Type:=msoControlButton) .Caption = "Print Graphs" .FaceId = 410 .OnAction = "Print_Graphs" End With Thanks. Look forward.. Best! -Ruchir On Jul 31, 2:26 pm, ytayta555 wrote: Try to write to the and of first code , the Call procedure : Call (name of your second macro) End Sub Maybe this help |
Activate second macro only after the first macro is run
at the end of your first macro, try
if msgbox ("Do you want to print the graphs?",vbyesno)=vbyes then call print_graphs else exit sub :) susan On Jul 31, 3:34*pm, Ruchir wrote: Thanks for the prompt reply! I thought of doing that. However, if we do that, the print_graphs macro will always run. I have to leave it to the user whether he wants to run the print_graphs macro or not. Here is what I am currently doing: * * Application.CommandBars("Worksheet Menu Bar") * * *Set cbcCutomMenu = _ * * * * *cbMainMenuBar.Controls.Add(Type:=msoControlPopup) * * * * *cbcCutomMenu.Caption = "Run &Macro" * * *With cbcCutomMenu.Controls.Add(Type:=msoControlButton) * * * * * * * * * * .Caption = "Draw Graphs" * * * * * * * * * * .FaceId = 418 * * * * * * * * * * .OnAction = "Draw_Graphs" * * *End With * * *With cbcCutomMenu.Controls.Add(Type:=msoControlButton) * * * * * * * * * * .Caption = "Print Graphs" * * * * * * * * * * .FaceId = 410 * * * * * * * * * * .OnAction = "Print_Graphs" * * *End With Thanks. Look forward.. Best! -Ruchir On Jul 31, 2:26 pm, ytayta555 wrote: Try to write to the and of first code , the Call procedure *: Call (name of your second macro) End Sub Maybe this help- Hide quoted text - - Show quoted text - |
Activate second macro only after the first macro is run
forgot
End If after exit sub susan On Jul 31, 4:13*pm, Susan wrote: at the end of your first macro, try if msgbox ("Do you want to print the graphs?",vbyesno)=vbyes then call print_graphs else exit sub :) susan On Jul 31, 3:34*pm, Ruchir wrote: Thanks for the prompt reply! I thought of doing that. However, if we do that, the print_graphs macro will always run. I have to leave it to the user whether he wants to run the print_graphs macro or not. Here is what I am currently doing: * * Application.CommandBars("Worksheet Menu Bar") * * *Set cbcCutomMenu = _ * * * * *cbMainMenuBar.Controls.Add(Type:=msoControlPopup) * * * * *cbcCutomMenu.Caption = "Run &Macro" * * *With cbcCutomMenu.Controls.Add(Type:=msoControlButton) * * * * * * * * * * .Caption = "Draw Graphs" * * * * * * * * * * .FaceId = 418 * * * * * * * * * * .OnAction = "Draw_Graphs" * * *End With * * *With cbcCutomMenu.Controls.Add(Type:=msoControlButton) * * * * * * * * * * .Caption = "Print Graphs" * * * * * * * * * * .FaceId = 410 * * * * * * * * * * .OnAction = "Print_Graphs" * * *End With Thanks. Look forward.. Best! -Ruchir On Jul 31, 2:26 pm, ytayta555 wrote: Try to write to the and of first code , the Call procedure *: Call (name of your second macro) End Sub Maybe this help- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text - |
Activate second macro only after the first macro is run
Thanks, Susan!
That would partially solve the problem. However, if the user clicks 'no' at first go and wants to print the graphs later, then he will have no option to do that. Basically, what I am trying to find out is: Is it possible to activate the print_graph macro only after the user clicks on draw_graph macro? If we do that, then the user can anytime print the graphs later, not just on the message prompt. Please let me know if you have any ideas. Looking forward.. Best, -Ruchir On Jul 31, 3:13 pm, Susan wrote: at the end of your first macro, try if msgbox ("Do you want to print the graphs?",vbyesno)=vbyes then call print_graphs else exit sub :) susan On Jul 31, 3:34 pm, Ruchir wrote: Thanks for the prompt reply! I thought of doing that. However, if we do that, the print_graphs macro will always run. I have to leave it to the user whether he wants to run the print_graphs macro or not. Here is what I am currently doing: Application.CommandBars("Worksheet Menu Bar") Set cbcCutomMenu = _ cbMainMenuBar.Controls.Add(Type:=msoControlPopup) cbcCutomMenu.Caption = "Run &Macro" With cbcCutomMenu.Controls.Add(Type:=msoControlButton) .Caption = "Draw Graphs" .FaceId = 418 .OnAction = "Draw_Graphs" End With With cbcCutomMenu.Controls.Add(Type:=msoControlButton) .Caption = "Print Graphs" .FaceId = 410 .OnAction = "Print_Graphs" End With Thanks. Look forward.. Best! -Ruchir On Jul 31, 2:26 pm, ytayta555 wrote: Try to write to the and of first code , the Call procedure : Call (name of your second macro) End Sub Maybe this help- Hide quoted text - - Show quoted text - |
Activate second macro only after the first macro is run
the only way i can think to accomplish that is to have a worksheet
button that they can push any time they want to.......... and you'd have to have a boolean value set up in draw_graph so that print_graph won't run if draw_graph hasn't already run in that instance. the boolean variable would have to be dimmed outside the procedures & be public. the button i think you're already doing with With cbcCutomMenu.Controls.Add(Type:=msoControlButton) your users can't have everything, don't they know that? ha ha good luck! susan On Jul 31, 4:20*pm, Ruchir wrote: Thanks, Susan! That would partially solve the problem. However, if the user clicks 'no' at first go and wants to print the graphs later, then he will have no option to do that. Basically, what I am trying to find out is: Is it possible to activate the print_graph macro only after the user clicks on draw_graph macro? If we do that, then the user can anytime print the graphs later, not just on the message prompt. Please let me know if you have any ideas. Looking forward.. Best, -Ruchir On Jul 31, 3:13 pm, Susan wrote: at the end of your first macro, try if msgbox ("Do you want to print the graphs?",vbyesno)=vbyes then call print_graphs else exit sub :) susan On Jul 31, 3:34 pm, Ruchir wrote: Thanks for the prompt reply! I thought of doing that. However, if we do that, the print_graphs macro will always run. I have to leave it to the user whether he wants to run the print_graphs macro or not. Here is what I am currently doing: * * Application.CommandBars("Worksheet Menu Bar") * * *Set cbcCutomMenu = _ * * * * *cbMainMenuBar.Controls.Add(Type:=msoControlPopup) * * * * *cbcCutomMenu.Caption = "Run &Macro" * * *With cbcCutomMenu.Controls.Add(Type:=msoControlButton) * * * * * * * * * * .Caption = "Draw Graphs" * * * * * * * * * * .FaceId = 418 * * * * * * * * * * .OnAction = "Draw_Graphs" * * *End With * * *With cbcCutomMenu.Controls.Add(Type:=msoControlButton) * * * * * * * * * * .Caption = "Print Graphs" * * * * * * * * * * .FaceId = 410 * * * * * * * * * * .OnAction = "Print_Graphs" * * *End With Thanks. Look forward.. Best! -Ruchir On Jul 31, 2:26 pm, ytayta555 wrote: Try to write to the and of first code , the Call procedure *: Call (name of your second macro) End Sub Maybe this help- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text - |
Activate second macro only after the first macro is run
hehe... you have a point!.. but i really wonder if it's not at all
possible in VB?!! thanks for your time and help. appreciate it. best, ruchir On Aug 1, 6:47 am, Susan wrote: the only way i can think to accomplish that is to have a worksheet button that they can push any time they want to.......... and you'd have to have a boolean value set up in draw_graph so that print_graph won't run if draw_graph hasn't already run in that instance. the boolean variable would have to be dimmed outside the procedures & be public. the button i think you're already doing with With cbcCutomMenu.Controls.Add(Type:=msoControlButton) your users can't have everything, don't they know that? ha ha good luck! susan On Jul 31, 4:20 pm, Ruchir wrote: Thanks, Susan! That would partially solve the problem. However, if the user clicks 'no' at first go and wants to print the graphs later, then he will have no option to do that. Basically, what I am trying to find out is: Is it possible to activate the print_graph macro only after the user clicks on draw_graph macro? If we do that, then the user can anytime print the graphs later, not just on the message prompt. Please let me know if you have any ideas. Looking forward.. Best, -Ruchir On Jul 31, 3:13 pm, Susan wrote: at the end of your first macro, try if msgbox ("Do you want to print the graphs?",vbyesno)=vbyes then call print_graphs else exit sub :) susan On Jul 31, 3:34 pm, Ruchir wrote: Thanks for the prompt reply! I thought of doing that. However, if we do that, the print_graphs macro will always run. I have to leave it to the user whether he wants to run the print_graphs macro or not. Here is what I am currently doing: Application.CommandBars("Worksheet Menu Bar") Set cbcCutomMenu = _ cbMainMenuBar.Controls.Add(Type:=msoControlPopup) cbcCutomMenu.Caption = "Run &Macro" With cbcCutomMenu.Controls.Add(Type:=msoControlButton) .Caption = "Draw Graphs" .FaceId = 418 .OnAction = "Draw_Graphs" End With With cbcCutomMenu.Controls.Add(Type:=msoControlButton) .Caption = "Print Graphs" .FaceId = 410 .OnAction = "Print_Graphs" End With Thanks. Look forward.. Best! -Ruchir On Jul 31, 2:26 pm, ytayta555 wrote: Try to write to the and of first code , the Call procedure : Call (name of your second macro) End Sub Maybe this help- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text - |
Activate second macro only after the first macro is run
i think it is possible but maybe an MVP or guru-type person would have
to help you. i'm not experienced enough. try posting in the excel.programming newsgroup with a link to this thread so they can see what's already been suggested......... susan On Aug 1, 12:03*pm, Ruchir wrote: hehe... you have a point!.. but i really wonder if it's not at all possible in VB?!! thanks for your time and help. appreciate it. best, ruchir On Aug 1, 6:47 am, Susan wrote: the only way i can think to accomplish that is to have a worksheet button that they can push any time they want to.......... and you'd have to have a boolean value set up in draw_graph so that print_graph won't run if draw_graph hasn't already run in that instance. *the boolean variable would have to be dimmed outside the procedures & be public. the button i think you're already doing with With cbcCutomMenu.Controls.Add(Type:=msoControlButton) your users can't have everything, don't they know that? *ha ha good luck! susan On Jul 31, 4:20 pm, Ruchir wrote: Thanks, Susan! That would partially solve the problem. However, if the user clicks 'no' at first go and wants to print the graphs later, then he will have no option to do that. Basically, what I am trying to find out is: Is it possible to activate the print_graph macro only after the user clicks on draw_graph macro? If we do that, then the user can anytime print the graphs later, not just on the message prompt. Please let me know if you have any ideas. Looking forward.. Best, -Ruchir On Jul 31, 3:13 pm, Susan wrote: at the end of your first macro, try if msgbox ("Do you want to print the graphs?",vbyesno)=vbyes then call print_graphs else exit sub :) susan On Jul 31, 3:34 pm, Ruchir wrote: Thanks for the prompt reply! I thought of doing that. However, if we do that, the print_graphs macro will always run. I have to leave it to the user whether he wants to run the print_graphs macro or not. Here is what I am currently doing: * * Application.CommandBars("Worksheet Menu Bar") * * *Set cbcCutomMenu = _ * * * * *cbMainMenuBar.Controls.Add(Type:=msoControlPopup) * * * * *cbcCutomMenu.Caption = "Run &Macro" * * *With cbcCutomMenu.Controls.Add(Type:=msoControlButton) * * * * * * * * * * .Caption = "Draw Graphs" * * * * * * * * * * .FaceId = 418 * * * * * * * * * * .OnAction = "Draw_Graphs" * * *End With * * *With cbcCutomMenu.Controls.Add(Type:=msoControlButton) * * * * * * * * * * .Caption = "Print Graphs" * * * * * * * * * * .FaceId = 410 * * * * * * * * * * .OnAction = "Print_Graphs" * * *End With Thanks. Look forward.. Best! -Ruchir On Jul 31, 2:26 pm, ytayta555 wrote: Try to write to the and of first code , the Call procedure *: Call (name of your second macro) End Sub Maybe this help- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text - |
All times are GMT +1. The time now is 10:28 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com