Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2006

Tip: Looking for answers? Try searching our database.

Macro Keyboard Shortcut

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Me - 21 Mar 2005 18:57 GMT
In Word 2003, how do I assign a keyboard shortcut to an already existing macro?

Thank you.
John - 21 Mar 2005 19:56 GMT
Tools/Customise.../Keyboard...

then select "Macros" from the left-hand listbox.

You can then select the correct macro and change its shortcut key.

Best regards

John

> In Word 2003, how do I assign a keyboard shortcut to an already existing
> macro?
>
> Thank you.
Jason - 15 Apr 2006 03:00 GMT
Is there any VBA code that will do this?  I would like to export a VBA file
and import to various PC's and not have to assign the key on every PC via the
Word menus.  Is this possible?

Thanks,

Jason

> Tools/Customise.../Keyboard...
>
[quoted text clipped - 10 lines]
> >
> > Thank you.
John - 15 Apr 2006 08:18 GMT
Hello Jason,

Lookup the "Keybindings" object in Help.  The example below is adapted from
that and seems to works ok.

Best regards

John

Sub Key()
'This example assigns the CTRL+SHIFT+B key
'combination to another procedure command
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl, _
   wdKeyShift, wdKeyB), KeyCategory:=wdKeyCategoryCommand, _
   Command:="MyFoundProcedure"
End Sub

Sub MyFoundProcedure()
   MsgBox ("Found")
End Sub

> Is there any VBA code that will do this?  I would like to export a VBA
> file
[quoted text clipped - 21 lines]
>> >
>> > Thank you.
Jason - 17 Apr 2006 16:37 GMT
Thanks, John.  I guess that I should have stated that I already tried this.  
Here is a copy of the code that I am using (this is in Word 97 if that
matters):

Sub LHAssignKey()
   CustomizationContext = NormalTemplate
   KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyF11), _
   KeyCategory:=wdKeyCategoryCommand, Command:="LetterHead"
End Sub

Sub LetterHead()
   With ActiveDocument.PageSetup
       .LeftMargin = Application.InchesToPoints(1)
       .RightMargin = Application.InchesToPoints(1)
       .TopMargin = Application.InchesToPoints(1.25)
       .BottomMargin = Application.InchesToPoints(0.75)
       .HeaderDistance = Application.InchesToPoints(0.25)
       .FooterDistance = Application.InchesToPoints(0.25)
       .DifferentFirstPageHeaderFooter = True
       .SectionStart = wdSectionNewPage
   End With
   ActiveDocument.Sections(1).Headers_
   (wdHeaderFooterFirstPage).Shapes.AddPicture _
   ("N:\Provider Audit\Templates\MISC\ugsheader.jpg")
   ActiveDocument.Sections(1).Footers_
   (wdHeaderFooterFirstPage).Shapes.AddPicture _
   ("N:\Provider Audit\Templates\MISC\ugsfooter.jpg")
   If ActiveDocument.Range.Font.Size > 10 Then
   Else
       Selection.WholeStory
       ActiveDocument.Range.Font.Size = 11
       Selection.HomeKey Unit:=wdStory
   End If
End Sub

> Hello Jason,
>
[quoted text clipped - 42 lines]
> >> >
> >> > Thank you.
Charles Kenyon - 18 Apr 2006 00:53 GMT
Didn't read the first post. Generally you do _not_ want normal.dot to be
your customization context. It makes your procedure look and feel a lot like
a virus to most users.
Signature

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!

My criminal defense site: http://addbalance.com
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

> Thanks, John.  I guess that I should have stated that I already tried
> this.
[quoted text clipped - 80 lines]
>> >> >
>> >> > Thank you.
Jason - 18 Apr 2006 12:16 GMT
Ok, well, even if I remove that line of code, it does not work.  Any other
suggestions?

Thanks,

Jason

> Didn't read the first post. Generally you do _not_ want normal.dot to be
> your customization context. It makes your procedure look and feel a lot like
[quoted text clipped - 83 lines]
> >> >> >
> >> >> > Thank you.
Charles Kenyon - 18 Apr 2006 15:17 GMT
Removing that line from your code leaves normal.dot, the default, as your
customization context.
This, though, is not the problem you wrote about and I have no advice on
that.
Signature

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!

My criminal defense site: http://addbalance.com
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

> Ok, well, even if I remove that line of code, it does not work.  Any other
> suggestions?
[quoted text clipped - 93 lines]
>> >> >> >
>> >> >> > Thank you.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.