Email this Page
Log Support Call
Send Feedback
Print |
|||||
Using Word Macros to Customize Your Word OutputAfter publishing your Word document, and provided you have Macros enabled, Author-it will automatically run the AfterPublish() macro if it exists in your template. If you have a piece of formatting you think Author-it doesn't do quite right, and it cannot be corrected in Author-it, this is the place to fix it! For this example, we have added a function called AddCellFormatting() that adds borders to cells containing the paragraph style "Table Body Text - Borders".
Private Sub AddCellFormatting(StyleName As String) ' Searches through the document looking for every ' instance of the style "Table Heading" and ensures ' that the borders are turned on for the cells ' containing text in this style. ' Created by Derek Tomes AuthorIT 7-Dec-2001 On Error Resume Next Dim cellInst As Cell ' Message to see if correctly added to template... MsgBox "This message lets you know you have enabled macros" & _ " and added the AddCellFormatting function correctly" & _ " into your template, it can be removed now." If Not ActiveDocument.Styles(StyleName).InUse Then ' Gets to here if: ' a) the style exists in the document but is not in use. ' b) the style does not exist in the document. Err.Clear Exit Sub End If ' Set the selection to the beginning of the document. Selection.StartOf wdStory With Selection.Find ' Search direction is forward. .Forward = True ' Clear any other previous search formatting. .ClearFormatting .Replacement.ClearFormatting .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False ' Search for the style indicating that the cell should have borders. .Style = ActiveDocument.Styles(StyleName) ' Search for every instance of this style. Do While .Execute ' Ensure that the selection is in a table. If Selection.Information(wdWithInTable) Then ' For each cell within the current selection. For Each cellInst In Selection.Cells ' Apply custom formatting here: ' To turn off any of these lines, remove or ' prefix with a single quote (') character.
' The following line adds a border around the selected cells... cellInst.Borders.Enable = True ' The following code line adds shading around the selected cells... ' to enable remove the single quote (') character at the beginning of the line:
'cellInst.Shading.BackgroundPatternColor = wdColorGray10 Next End If ' Move to the next paragraph Selection.Move wdParagraph, 1 Loop End With ' Remove any undo history to prevent Word.doc bloat. ActiveDocument.UndoClear End Sub |
|||||
| Top of Page |
Email this Page
Log Support Call
Send Feedback
Print |
||||
|
|||||