DataBaseZone.com
Conrad Muller
Juneau, Alaska

Email: conrad at
databasezone
dot com

Microsoft Word Application to Generate Form Letters


An exercise for a beginning programming class.

Option Explicit
----------------------------------------------------------------------------------

' Run this procedure when the document opens.
Private Sub document_open()

' Select the current document and minimize it.
Documents(Me).Activate
ActiveWindow.WindowState = wdWindowStateMinimize

' --------------
' Assigns the module ShowForm() to the shortcut keys Alt+L

' Set the current document as the location of the code to be run.
CustomizationContext = ActiveDocument

' Define Alt+L as the KeyCode in the KeyBindings container.
KeyBindings.Add KeyCode:=BuildKeyCode(Arg1:=wdKeyAlt, Arg2:=wdKeyL), _
KeyCategory:=wdKeyCategoryMacro, Command:="ShowForm" ' Link the KeyCode to the module "ShowForm"
' --------------

' Now load and show the UserForm.
ShowForm

End Sub
----------------------------------------------------------------------------------

' This procedure loads and shows the UserForm "frmSalesLetter"
Sub ShowForm()

Load frmSalesLetter ' Loads the form into memory.
frmSalesLetter.Show ' Shows the form on the screen.

End Sub

Home | Resume | Project Portfolio | Writings | Developer Resources | Contact Form