Search

Help

Home


10 Great Word Toolbar Macros

Signature Checkbox Change printer bin Fax/Printer Change directory Load another toolbar Open a file New template - specific type WordCount Footer with the filename and path

Here are some great macros to speed up your work in Word 6.0 and 7.0 from Helen Bradley.

Play ScreenCam
tutorial Part 1

Play ScreenCam
tutorial Part 2


Figure 1: You can customise the printer/fax macro to your own system by determining what your printer and fax is called and adapting the macro to suit.



Signature

Add your signature to a letter or memo with this handy macro. You'll need a copy of your signature scanned and saved as an image file.

Sub MAIN

InsertFrame
InsertPicture .Name = "C:\GRAPHICS\HELENB.TIF", .LinkToFile = "2"
CharRight 1

End Sub

Substitute the filename and path of your signature file in line 2 of the macro. The macro creates a frame and adds the graphic to it. The .LinkToFile = "2" means the graphic is referenced on disc and not saved with the document, thus saving space. If the document is to be moved to another machine, use .LinkToFile = "0" instead and the graphic will be saved with the file.

Don't own a scanner? If you have access to a fax-modem, send a self-signed fax to yourself, view the signature part of the fax and use PrintScreen to take a copy of the screen. Paste the image into Paint Shop Pro, and crop and save as a BMP, TIP, PCX etc.


Figure 2: This button toggles display and hiding a custom directory changing toolbar.


Checkbox

Use this macro to add a tick/checkbox in the current font and size at the cursor position:

Sub MAIN

InsertSymbol .Font = "Wingdings", .CharNum = "113"

End Sub

All the macros listed here can be found in macros.txt in the \interact\macros\ directory on the CD Change printer bin

If your printer has two bins, this macro tells you which bin is selected and offers to change it for you:

Sub MAIN

Dim currPrnBin As ToolsOptionsPrint
GetCurValues currPrnBin
msg$ = "The current bin is: " + Chr$(13) + currPrnBin.DefaultTray
msg$ = msg$ + Chr$(13) + "Change?"
title$ = "Change Printer Tray?"
userReply = MsgBox(msg$, title$, 292)
If userReply = - 1 Then
If currPrnBin.DefaultTray = "Lower tray" Then
ToolsOptionsPrint .DefaultTray = "Upper tray"
Else
ToolsOptionsPrint .DefaultTray = "Lower tray"
EndIf
EndIf

End Sub

Our printer allows us to select between Upper and Lower trays. Check in Tools, Options, Printers for the names of the trays available for your printer and if they differ from ours, adjust your macro accordingly.

To create the macros

Step 1: Select Tools, Macro and type a name for your macro in the Macro Name box.

Step 2: Click Create and paste or type the text of the macro in-between the Sub Main . . . End Sub statements (you should have only one set of Sub Main . . . End Sub statements per macro).

Step 3: Select File, Close and select Yes when prompted to Keep changes to the macro.

Adding a macro to the toolbar

Step 1: Select View, Toolbars, Customize.

Step 2: Select Macros in the Category list.

Step 3: Select your macro from the Macros list and drag the macro name to your toolbar (it turns into a button as it goes).

Step 4: Select a button face or type suitable text for the button in the Custom Button dialogue box.

Step 5: Select Assign and Close.

Tips for naming macros

Do not use any spaces, commas or periods in your macro names.

Choose macro names that suggest the purpose of the macro.

If a macro is assigned to a button on the toolbar its name becomes the button's tooltip. A macro called 'changeprinterbin' will have the tool tip changeprinterbin, but if you use mixed case and call it 'ChangePrinterBin' its tooltip will be Change Printer Bin!

Changing the name of a macro

Step 1: Select Tools, Macro, Organizer.

Step 2: Select the macro in the list box on the left of the screen.

Step 3: Select the Rename button and type the new name.

Step 4: Click OK and then Close.

Fax/printer

Do you have a fax-modem on your computer? This macro allows you to toggle between printing to the fax and your printer:

Sub MAIN

Dim currentPrinter As FilePrintSetup
GetCurValues currentPrinter
If currentPrinter.Printer = "Quick Link II Fax on FAX/MODEM" Then
FilePrintSetup .Printer = "HP LaserJet IIP on LPT1:"
Else
FilePrintSetup .Printer = "Quick Link II Fax on FAX/MODEM"
EndIf

End Sub

The printer descriptions in this macro relate to the printer names on our machine (see Figure 1). Select File, Print, Printer and in the Printers list are the printer descriptions which you should use in your macro.

If you are unsure of the exact printer descriptions to use, record a simple macro to select each of your printer and your fax and cut and paste the printer descriptions into this macro.

Change directory

This macro changes the current document directory to C:\MSOFFICE\WINWORD6\DOX. Change the 0 to a 1 to change the picture path instead:

Sub MAIN

ChDefaultDir "C:\MSOFFICE\WINWORD6\DOX\", 0

End Sub

Load another toolbar

Add this macro to a button on a visible toolbar to toggle display and hiding of a custom (or WinWord shipped) toolbar -- in this case it displays and hides a toolbar called MyToolbar. Figure 2 shows a button for hiding and displaying a custom directory changing toolbar:

Sub MAIN

If ToolbarState("MyToolbar") Then
ViewToolbars .Toolbar = "MyToolbar", .Hide
Else
ViewToolbars .Toolbar = "MyToolbar", .Show
EndIf

End Sub

Don't know what a toolbar is called? Use View, Toolbars and read the name from the list. Note that Toolbars are allowed to have spaces in their names.

Open a file

This macro changes the default document directory to C:\MYDOX\ and opens the file todolist.txt from that directory.

Sub MAIN

ChDefaultDir "C:\mydox \", 0
FileOpen .Name = "todolist.txt"

End Sub

This macro is similar in that it opens the file but instead it leaves the current document directory unchanged:

Sub MAIN

FileOpen .Name = "C:\mydox\todolist.txt"

End Sub

New template - specific type

This macro opens a new file using the Faxcovr1 template:

Sub MAIN

FileNew .Template = "Faxcovr1", .NewTemplate = 0

End Sub

Word count

A word count macro already exists as a Word command. Add a button to run it to a toolbar by selecting View, Toolbars, Customize. From the Categories list select All Commands and from the Commands list click on ToolsWordCount and drag a button to your toolbar. In the Custom Button dialogue box select a button face or type suitable text for the button and select Assign, and Close.

Footer with the filename and path

This macro adds the full filename and path to the footer in 8pt Italic type:

Sub MAIN

ViewFooter
FontSize 8
Italic
InsertField .Field = "FILENAME \p \* MERGEFORMAT"
CloseViewHeaderFooter

End Sub


Top of page

|What's New | Software | Net Guides | Web Workshop | Net Sites | About PC User |

All text © 1997 Australian Consolidated Press - PC User Magazine