PDA

View Full Version : Word 2007 shortcut to open the UserForm



cjcant
05-30-2011, 04:46 AM
Hi,

I am attempting to get my userForm to open without going into the VBA editor then 'run'. I have tried creating a shortcut but it is not bringing the userform up. Is it possible for somebody to please give me a walkthrough of how to create a shortcut for e.g. CTRL+SHIFT+O. (It keeps opening the panel that includes dictionary and thesaurus).

Thanks

Frosty
05-31-2011, 02:28 PM
I'm guessing from the font brackets in your post that you've copied/pasted this and cross-posted elsewhere.

You need to do something along the lines of this:
1. Create a regular basic module in the same template/document you have your userform in.
2. Always have "Option Explicit" at the top of modules.
3. Within the module, something like the following code:

Public Sub HelloWorld
Dim f as MyUserForm 'replacing "MyUserForm" with the actual name of the form-- whether it's UserForm1 or frmSomeForm or whatever
Set f = New MyUserForm 'same as above
f.Show

On Error Resume Next
set f = nothing
End Sub
4. Right-click on the Ribbon
5. Choose Customize Quick Access Toolbar
6. Click Customize to the right of Keyboard Shortcuts
7. Under categories (on the left), scroll all the way down to Macros and select it
8. Under Commands, select HelloWorld (or whatever you rename your macro to)
9. Select the short-cut key combo you want to use (if you are distributing this macro project, you should think about the impact of replacing existing keyboard combos)
10. Choose where to save the changes in (typically, not normal.dotm, but rather the template you have your code in).
11. Voila-- you should be able to use your keyboard shortcut to run your macro which shows your form.

Good luck.

cjcant
06-01-2011, 12:53 AM
Thanks that is a great help! :biggrin: