Macros

The file Macros.dotm contains a collection of macros and classes that I have developed for Microsoft Word 2007. You can examine the contents of the template through this report, which was generated by the macro ReportTemplateInfo.

Note: My copy of this file is installed in the Word start-up folder so that these macros are automatically loaded when Word is launched. I moved these macros and classes out of my Normal template into this stand-alone file.

Macros

MacroModuleDescription
ColorAutofnWordSet the color of the selection to automatic
ColorBluefnWordSet the color of the selection to blue
ColorRedfnWordSet the color of the selection to red
CompareStylesfnReportsProduce a report comparing the styles between two documents
ConvertFieldsToTextfnFieldsConvert fields in the current document to text
ConvertReferencesToTextfnFieldsConvert references to text of the form "<<reference>>"
ConvertRefFieldsToRefNamesfnFieldsConvert references in fields to text of the form "<<name>>"
ConvertTextToRFCfnConversionFormat the current document as an Internet RFC
ConvertTOCtoTextfnWordConvert the Table of Contents to text
CopyFontfnWordCopy the font styling of the current selection
DelinkPicturefnWordFind the next picture and disconnect it from the source document
DisplayInformationfnWordDisplay information about the current selection (Selection.Information)
DisplaySaveDatefnWordDisplay the last saved time for the current document
DisplaySelectionfnWordDisplay the current selection (as text and codes)
DisplayStartUpLocationfnWordDisplay the location where Word looks for add ins
DisplayTemplateLocationfnWordDisplay the location where Word looks for document templates
EmitCodeForAllHeadingsfnEmitCodeCreate calls to ResetNumbering that match the current document list levels
EndOfCellfnWordMoves the cursor to the end of the current cell
FindAutomaticallyResizefnSearchFind the table or cell that is set to automatically resize
FindAutomaticPageBreakfnSearchFind the next automatic page break in the document
FindEmptyCellfnSearchFind the next empty cell in the document
FindEmptyRowfnSearchFind the next row in the document where all cells are empty
FindFieldsOfZerofnFieldsFind fields in the current document where the text is "0"
FindFlagfnSearchFind next instance of **#**
FindMarkerfnSearchFind next instance of <<>>
FindRevisionByfnRevisionsFind revisions made by a specific author
FindRowAboveHeightfnSearchFind the next row that exceeds a certain height
FindRowBreakablefnSearchFind the next row in the document where "Allow row to break..." is set
FindRowNotKeepWithNextfnSearchFind the next row in the document where "Keep with next" is not set
FindRowSizedfnSearchFind the next row in the document where the height is set manually
FixBoldFieldsfnFieldsFind fields with bold formatting and turn it off
HideFieldCodesfnWordTurn off the display of field codes
HowToaDocumentationShow tricks and tips for Visual Basic
NewFaxFormNewFaxFormGenerate a new fax form
PasteFontfnWordPaste the font styling into the current selection
PastePlainfnWordPaste the clipboard exactly (without "Smart Cut and Paste")
ReportBookmarksfnReportsProduce a report of the bookmarks in the current document
ReportBuiltinPropertiesfnReportsProduce a report of the properties of the current document
ReportReferencesfnReportsProduce a report of references required by the current document
ReportStylesAllWithDescriptionsfnReportsProduce a report of all known styles and their descriptions
ReportStylesBuiltinfnReportsProduce a report listing the built-in styles
ReportStylesNotInUsefnReportsProduce a report listing the styles that are not used in the current document
ReportStylesReallyInUsefnReportsProduce a report listing the styles used in the current document
ReportStylesReallyInUseWithDescriptionsfnReportsProduce a report listing the styles used in the current document and their descriptions
ReportTemplateInfoReportTemplateInfoProduce a report with information about a template
ReportTemplateMacrosAsHTMLReportTemplateInfoProduce HTML tables with macro and class entry lists
ReportWhoRevisedfnRevisionsProduce a report showing every author who made revisions to the current document
RevisionsAcceptfnRevisionsAccept the revisions of the current selection
RevisionsAcceptFieldsfnRevisionsAccept revisions of fields (typically generated as a result of printing while revisions are turned on)
RevisionsAcceptOldfnRevisionsAccept revisions of changes made before a user-specified date
RevisionsAcceptRefFieldsfnRevisionsAccept revisions of reference fields
RevisionsDeletefnRevisionsConvert the selection to deleted text
RevisionsFindNewestfnRevisionsFind the newest revision in the current document
RevisionsHidefnRevisionsTurn off the display of revision marks
RevisionsInsertfnRevisionsConvert the selection to inserted text
RevisionsNextfnRevisionsGo to the next revision
RevisionsOfffnRevisionsTurn off revision marking
RevisionsOnfnRevisionsTurn on revision marking
RevisionsPreviousfnRevisionsGo to the previous revision
RevisionsRejectfnRevisionsReject the revisions of the current selection
RevisionsReviewfnRevisionsReview the current revision (author and date)
RevisionsShowfnRevisionsTurn on the display of revision marks
SelectNextParafnWordSelect the next paragraph
SelectParafnWordSelect the entire paragraph containing the cursor
SelectToEndOfCellfnWordSelect text from the cursor to the end of the current cell
SelectToStartOfCellfnWordSelect text from the start of the current cell to the cursor
ShowCommentsfnWordShow the comments pane
ShowEndnotesfnWordShow the endnotes pane
ShowFieldCodesfnWordTurn on the display of field codes
ShowFootnotesfnWordShow the footnotes pane
ShowRevisionsfnWordShow the revisions pane
StartOfCellfnWordMove the cursor to the beginning of the current cell
TableNextfnWordGo to the next table
TablePreviousfnWordGo to the previous table
TryAllFontsfnReportsProduce a report showing a user-selected string rendered in all available fonts

Classes

ClassDescription
Contextsaves information so that macros do not inadvertently change the experience the user has after a macro ends
FindFontdefines an object mimicing Find that can be passed to Lib.Find or Lib.FindReplace
FindReplacementdefines an object mimicing FindReplacement that can be passed to Lib.Find or Lib.FindReplace
Libutility functions and routines for use by macros
Reportsupports generation of macro reports

Class: Context

Entry PointDescription
Purgepurges bookmarks left behind by saved locations
Restorerestores location, Edit->Find, revision marking, and screen updating
RestoreFindrestores the state of the Edit->Find dialog
RestoreLocationrestores the cursor position
Savesaves location, Edit->Find, revision marking, and screen updating
SaveFindsaves the state of the Edit->Find dialog
SaveLocationsaves the cursor position

Class: FindFont

Entry PointDescription
ClearFormattingclears all formatting

Class: FindReplacement

Entry PointDescription
CopyFromcopies fields into the object
CopyTocopies fields out of the object
ClearFormattingclears all formatting

Class: Lib

Entry PointDescription
AddVBAExtensibilityenables "Microsoft Visual Basic for Applications Extensibility"
AdvanceLocationadvances to the next location (returns boolean)
AdvanceToLocationadvances to the next location (returns location or atEnd)
AtEndOfDocumentreturns a boolean value indicating if the cursor is at the end of the document.
BringToTopactivates a window and brings it to the front of all other document windows
CellHeightreturns the approximate height (in points) of the active cell
CopyFontsaves information about the font characteristics of the selection
CurrentCellreturns the active cell
DuplicateBorderscopies one Border object to another [except line styles]
DuplicateFontcopies one Font/FindFont object to another
DuplicateParagraphFormatcopies one ParagraphFormat object to another [except TabStops]
DuplicateStylecopies one Style object to another
EndOfCellreturns a boolean value indicating if the cursor is at the end of a cell.
FieldToBookmarkextracts the bookmark name from a field and returns the bookmark
Findsearches the document for text (with optional formatting)
FindReplacereplaces text in the document (with optional formatting)
FormatTextformats a string with the values of special characters
GoToContentpositions the cursor at the start of the document body
GoToLocationpositions the cursor in the requested location
Locationreturns the location of the cursor
NewDocumentcreates a new document with requested template, orientation, and margins
NextCelladvances the selection to the next cell (if any) in the current table
NextHeaderFooteradvances to the next header or footer (if any)
NextLocationreturns the next location for the cursor
NextRowselects the next row in the current table
NextSearchableadvances to the next searchable location
NextTextBoxadvances to the next text box (if any)
PasteFontapplies information about the font characteristics of the selection
PreviousCellreturns the previous cell (if any) in the current table
PreviousRowselects the previous row in the current table
SelectNextChunkselects the next chunk (paragraph or cell) in the document
SelectParaselects the current paragraph
SelectToEndOfCellselects from the cursor to the end of the current cell
SelectToStartOfCellselects from the cursor to the start of the current cell
SetViewchanges the view of the ActiveWindow and returns the previous state
ShowConsoleshows the debugging console (Notepad)
ShowTextdisplays a message box showing the values of special characters
StartOfCellmoves the cursor to the start of the current cell
statussets the text in the status dialog
StatusStopPushedreturns True if the user pressed the Stop button in the status dialog
StepLocationsteps within the current location or advances to the next location
TableNextmoves the cursor to the next table in the document
TablePreviousmoves the cursor to the previous table in the document
TopMostmakes a window stay on top of of all other windows
WriteToConsolewrites a string to the debugging console (Notepad)

Class: Report

Entry PointDescription
Activateactivates the report window
AddCellsets the text of the next table cell
AddTableadds a table to the report
Documentreturns the report's Document object
Emitinserts a string into the report
EndTableends the table being added to the report
Fontreturns the Font object for the current selection in the report
Formatformats the report: orientation, margins, and template
Headingadds a heading to the report
MoveLeftmoves the cursor left within the report
MoveRightmoves the cursor right within the report
SelectAllselects the entire report
Selectionreturns the current selection in the report
StyleHeadingsets the style that will be used for report headings
StyleReportsets the style that will be used for report text
Warninserts a warning string (with red text) into the report

Documentation

Additional documentation can be found in the inline comments.

Send me reports of any errors or suggestions you have about my VBA modules.


This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.