- The following macro will print all your current fonts in their font to a document. To create the macro open Word, then select the Macro item from the Tools Menu, followed by the Macros option. Enter the name of the macro, in this instance ListFonts and click on the Create button. When the Visual Basic editor opens enter the code as shown below.
|
Sub ListFonts()
'
' ListFonts Macro
' Macro created 12/04/01 by Kevin Clark
'
Dim MyFontList As Variant
Documents.Add Template:="Normal"
' Align All Text to Centre of Page
ActiveDocument.Paragraphs.Alignment = wdAlignParagraphCenter
' Hide Updates for now, speeds the macro up
Application.ScreenUpdating = False
For Each MyFontList In FontNames
With Selection
.Font.Name = MyFontList
.TypeText Text:=Chr(11)
.Font.Size = 14
.TypeText MyFontList + Chr(11)
.Font.Name = MyFontList
.TypeText "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + Chr(11)
.TypeText "abcdefghijklmnopqrstuvwxyz" + Chr(11)
.TypeText "0123456789?£@%&()[]{}*_-=+/<>~"" + Chr(11)
.InsertParagraphAfter
.MoveDown Unit:=wdParagraph, Count:=1, Extend:=wdMove
End With
Next MyFontList
' Sort the Fonts
Selection.WholeStory
Selection.Sort
Selection.HomeKey Unit:=wdStory
Application.ScreenUpdating = True
End Sub
|
- To add a button on the toolbar to print the current page follow the steps outlined below:
|
1. Select the Tool menu, and click on the Macro menu option and then select the Macros sub option.
|
2. When the Macros dialog box appears enter the name for the macro in the Macro Name box, we'll call it PrintCurrentPage. Now select the Create button.
|
3. Word's Visual Basic editor now appears with the name of the routine on the top line. Following the comment about the date of creation enter.
|
ActiveWindow.PrintOut Range:=wdPrintCurrentPage
|
Just close the current Window once done.
|
4. To add a button to a toolbar, again select the Tools menu, and then the Customise option.
|
5. Select the Commands tab and scroll down the Categories and select the Macros Option.
|
6. The macro you just created will be listed in the commands pane. Drag and Drop this entry onto the destination toolbar.
|
7. A large button will appear with a long name. With the Customise menu still open right click the button and amend the button name and image as required.
|
- The following macro is an extension of the one above additionally showing the Euro sign for all the fonts on your system. To create the macro open Word, then select the Macro item from the Tools Menu, followed by the Macros option. Enter the name of the macro, in this instance ListFonts and click on the Create button. When the Visual Basic editor opens enter the code as shown below.
|
Public Sub ListEuroFonts()
' ListFonts Macro
' Macro created 09/04/02 by Kevin Clark
'
Dim vntFont As Variant
Dim intCount As Integer
intCount = 1
' List all the fonts
For Each vntFont In FontNames
With Selection
.TypeText intCount
.TypeText Chr(9)
.Font.Name = vntFont
.TypeText Chr(128)
.TypeText Chr(9)
.TypeText vntFont
.TypeText Chr(9)
.Font.Name = "Courier New"
.TypeText vntFont
.TypeText Chr(13)
End With
intCount = intCount + 1
Next vntFont
'Select the whole document
Selection.HomeKey unit:=wdStory, Extend:=wdExtend
'Convert to a table
Selection.ConvertToTable Separator:=wdSeparateByTabs, numrows:=intCount - 1, numcolumns:=4, Format:=wdTableFormatNone, applyborders:=True, applyshading:=True, applyfont:=True, applycolor:=True, applyheadingrows:=True, applylastrow:=False, applyfirstcolumn:=True, applylastcolumn:=False, AutoFit:=True
'Sort the table
Selection.Sort excludeheader:=False, fieldnumber:="Column 4", SortFieldType:=wdSortFieldAlphanumeric, sortorder:=wdSortOrderAscending, Separator:=wdSortSeparateByTabs, sortcolumn:=False, casesensitive:=False, LanguageID:=wdEnglishUK
'Autofit to contents
Selection.Tables(1).AutoFormat Format:=wdTableFormatSimple1, applyborders:=False, applyshading:=False, applyfont:=False, applycolor:=False, applyheadingrows:=False, applylastrow:=False, applyfirstcolumn:=False, applylastcolumn:=False, AutoFit:=True
'Go to the beginning
Selection.HomeKey unit:=wdStory
End Sub
|
- To create a date field on a word document that shows when the document was created then select Insert->Field, then choose the CREATEDATE field and press the options button to select the required date format. Using Insert->Date and Time will insert the current date and time which is updated whenever the document is opened, printed or when the user presses the F9 key.
- To stop Word starting up with a blank document already open run Word with the command line 'winword.exe /n'.
- To get a list of all the Menu and Keyboard Shortcuts, go to the Tools Menu, select Macro and then Macros. Once the dialog is open, click on the down arrow next to the Macros In combo box, and select Word Command entry. Scroll through the list of commands until you find 'ListCommands', select it then hit the Run button. A small dialog box will appear asking if you want the current menu and keyboard settings only, or a list of all Word commands. After making your selection, click on OK and a new document will be created containing a table with all the commands you requested.
- You can easily change the font and font size without ever lifting your hands from the keyboard. To change the font, press Ctrl + Shift + F. This will select the Font box. Next you can press the Up and Down arrows to select the font you want to use. After you make a selection, press Enter. To change the font size, press Ctrl + Shift + P and then use the Up and Down to select a font size. Press Enter after you make a selection.
- To keep words on the same line you can use Word's non-breaking space. For example, type in "Mortimer," then press Ctrl + Shift + Spacebar, and then type in "Brewster." Using the non-breaking space will ensure that Mortimer and Brewster always stay on the same line.
- To change the number of files in your recently opened files list select Tools->Options and the General Tab and amend the value in the Recently Used File List.
- When opening a file with File->Open you can use Alt and n where is between 1 and 9 to access the toolbar buttons in the file open dialog box.
|
|
|