Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to activate command button on form by macro
I'm working on a macro to load, fill out, and run a form. I think I
know how to do everything except run the form. By run the form I mean "click" the OK command button. Here's basically what I have (in the same workbook as the form): Load MyForm MyForm.textbox = "some text" MyForm.OKbutton.SetFocus Application.SendKeys "{ENTER}" I thought I could set the focus to the OK command button and send the ENTER key but that isn't working. Should this work or is there some other way to click the OK command button? Denis |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to activate command button on form by macro
By default when you created the OKbutton the click event procedure will be
private so it will look something like... Private OKbutton_Click() This means the the procedure is not exposed outside of the form. To expose it you just need to change it to Public Public OKbutton_Click() Now you can call it like this... call MyForm.OKbutton_Click() You do not need to load the form. In fact that will halt the execution waiting for user input on the form. -- HTH... Jim Thomlinson "Denis" wrote: I'm working on a macro to load, fill out, and run a form. I think I know how to do everything except run the form. By run the form I mean "click" the OK command button. Here's basically what I have (in the same workbook as the form): Load MyForm MyForm.textbox = "some text" MyForm.OKbutton.SetFocus Application.SendKeys "{ENTER}" I thought I could set the focus to the OK command button and send the ENTER key but that isn't working. Should this work or is there some other way to click the OK command button? Denis |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to activate command button on form by macro
On Oct 24, 1:09 pm, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
This-.com wrote: By default when you created the OKbutton the click event procedure will be private so it will look something like... Private OKbutton_Click() This means the the procedure is not exposed outside of the form. To expose it you just need to change it to Public Public OKbutton_Click() Now you can call it like this... call MyForm.OKbutton_Click() You do not need to load the form. In fact that will halt the execution waiting for user input on the form. -- HTH... Jim Thomlinson Thanks. I wondered if that was the right approach or if there was a better or right way to do this. Denis "Denis" wrote: I'm working on a macro to load, fill out, and run a form. I think I know how to do everything except run the form. By run the form I mean "click" the OK command button. Here's basically what I have (in the same workbook as the form): Load MyForm MyForm.textbox = "some text" MyForm.OKbutton.SetFocus Application.SendKeys "{ENTER}" I thought I could set the focus to the OK command button and send the ENTER key but that isn't working. Should this work or is there some other way to click the OK command button? Denis |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
macro attached to command button - VBA form | Excel Discussion (Misc queries) | |||
Accessing the text of a form command button from underlying macro | Excel Programming | |||
Command Button vs Form Button | Excel Programming | |||
Macro to activate form button | Excel Programming | |||
using 'enter' on a textbox to activate a command button? | Excel Programming |