then create the macro, forget about using "hotkeys" such as F9.
Sample of a Memo template below minus formatting and embedded logos;
GoldPlate Motors
Inter Office Memo
To:
From: Jeff
Date: 20/02/2008
Subject:
The macro is one I wrote three years ago as part of an assessment, the profuse use of REM statements is to prove I understood the code. A mate of mine said it was "overblown and he could have written a shorter script, and I'm sure there are many members here who could write a better one.
You will need to create you own autorun.exe file. The macro is designed to run a dialog box that requires the addressee, date and you should not be able to save the file unless you have a this data.
The dialog boxes pop up and ask for the information and once you click on ok it will move the cursor to the next location on the template and another dialog box will pop up until your reach the point where you enter the text of the memo.
If you cut and paste the Memo Template into a word document and save it as a template, then go to tools and open the visual basic editor and copy the macro into there, save and reopen the template, select the macro and run. If you want the macro to start automatically you will need to in create your own autorun.exe to include.
Sub GoldPlateMotors1()
' GoldPlateMotors1 Macro
' Macro recorded 18/10/2005 by Jeff Cook
Rem Ask for Recipients Name,if empty string calls error check funcion and requests close or restart
'Declare variables
Dim inpstring As String
inpstring = InputBox("Please enter the Recipients Name", "Recipients Name") 'Requests name
If (inpstring = "") Then 'Function "If" and empty string calls Function "Check_for_Close_or_Restart"
Call Check_for_Close_or_Restart 'Calls Function
Else
GoldPlateMotors2 (inpstring) 'Goes to Subroutine GoldPlateMotors2 if string <>"" and passes declared variable in
End If 'inpstring Subroutine GoldPlateMotors2 this negates the having to declare inpstring
'as a varible in Subroutine GoldPlateMotors2
End Sub
Sub GoldPlateMotors2(inpstring As String) 'Imports Variable inpstring
'Executes if inpstring <>"" or Function "Check_for_Close_or_Restart" initiates
Selection.GoTo What:=wdGoToBookmark, Name:="To" 'Gets Bookmark
Selection.Text = inpstring 'Inserts text typed into Input Box
Selection.GoTo What:=wdGoToBookmark, Name:="Date" 'Gets Bookmark
inpstring = InputBox("Please enter the Date", "Date", Date) ' Input Box requests Date
Selection.Text = inpstring 'Inserts current date by "OK" or allows dare to be altered(not recommended)
Selection.GoTo What:=wdGoToBookmark, Name:="Subject" 'Gets Bookmark
inpstring = InputBox("Please enter the Subject", "Subject") '
Selection.Text = inpstring 'Inserts text typed into Input Box
Selection.GoTo What:=wdGoToBookmark, Name:="Body" 'Gets Bookmark
Selection.Text = "" 'Allows text to be inserted into the body of the Memo
With ActiveDocument.Bookmarks 'Describes bookmarks in the active document as being sorted
.DefaultSorting = wdSortByLocation 'by "Location" rather than "Name" and hidden bookmarks can
.ShowHidden = False 'be displayed
End With
End Sub
Public Function Check_for_Close_or_Restart() As Integer 'Function called by "If" Function in GoldPlateMotors1 when
'instring = ""
'Function requires value when a Function is called from
'within, the MsgBox and InputBox are Functions
'hence declared variables are the value
'Declare variables
Dim inpstring As String
Dim response As Integer
response = MsgBox("Do you wish to Close this Program", vbYesNo, "Close") 'Function Error check
If response = vbYes Then 'If val = 6,vbYes Close
ActiveDocument.Close
Application.Quit '
Else 'Else val = 7,vbNo
response = MsgBox("This will restart the macro!", vbOKOnly, "Restart") '"OK" to restart the macro
inpstring = InputBox("Please enter the Recipients Name", "Recipients Name") 'If val =1, vbOKOnly,restarts macro
GoldPlateMotors2 (inpstring)
End If
End Function