PRB: Lists in Word Cause Numbering Problems When Saved As RTFLast reviewed: March 18, 1998Article ID: Q182336 |
The information in this article applies to:
SYMPTOMSWhen you save a document in Rich Text Format (RTF) in Microsoft Word 97 for Windows to generate Help (.hlp) files with the Microsoft Help Compiler, unwanted line numbering may precede paragraphs in the help source file. The document does not show these line numbers in Word 97.
CAUSEThis problem occurs in Word when you choose to continue a previous list, but there are non-list paragraphs between the two lists. The list can be either a bulleted or a numbered list. Word places RTF codes after the first list which indicates that line numbering should continue silently, as in the example below:
{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }The codes in the example above specify the following:
\*\pn = line numbering \pnlvlcont = continue line numbering but silently (don't display on screen) \ls0 = the list id that should be continued \pndec = the list is decimal (1,2,3)However, these codes are unnecessary. Word relies on the list id (/ls#) to determine whether a list should continue a previous list. When you take those codes out of the RTF file, Word still renders the file correctly. Hence, the additional RTF codes cause the Help compiler to place line numbers on every paragraph between the two lists.
WORKAROUNDThe Help compiler does not allow you to continue a previous automatically numbered list. To generate this effect, turn off automatic numbering. To turn off Automatic numbering, follow these steps:
NOTE: Because bulleted lists do not provide the option to continue a previous list, this situation is more rare. When it occurs it is more difficult to solve, because you can not turn off the "continue previous list" option for bullets.
MORE INFORMATIONMicrosoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/refguide/default.aspThe following Word 97 code fixes any RTF document where bulleted lists are causing the problem. The code cycles through each paragraph. If the current paragraph is in a list, it copies the formatting of the list. It then removes the list attribute and reapplies it. By default, these actions remove any continuation of previous lists. Note that this will cause separate numbered lists that were previously continuous to begin renumbering after each break. However, since the Help files can not render this type of list, that problem will need to be dealt with separately anyway by manually typing in the list numbers.
Sub BulletFix() ' ' BulletFix Macro ' Dim par As Object ' Cycle through all paragraphs in document For Each par In ActiveDocument.Paragraphs ' Select paragraph par.Range.Select ' Save its ListTemplate (its formatting) Dim lt As ListTemplate Set lt = Selection.Range.ListFormat.ListTemplate If TypeName(lt) <> "Nothing" Then Dim FirstLine As Double Dim LeftIndent As Double FirstLine = Selection.ParagraphFormat.FirstLineIndent LeftIndent = Selection.ParagraphFormat.LeftIndent ' Remove Bullets/Numbers Selection.Range.ListFormat.RemoveNumbers _ NumberType:=wdNumberParagraph ' Restore the list format Selection.Range.ListFormat.ApplyListTemplate _ ListTemplate:=lt, ApplyTo:=wdListApplyToWholeList ' Restore Indentation Settings Selection.ParagraphFormat.FirstLineIndent = FirstLine Selection.ParagraphFormat.LeftIndent = LeftIndent End If Next ' Go back to the beginning of the document Selection.HomeKey Unit:=wdStory End SubDeleting the problematic RTF codes should be the last option. In this case, keep a backup copy of the RTF file (in case the wrong codes are deleted). The file could become corrupt and unreadable by Word. For more information about the Listformat Property, while in the Visual Basic for Applications Editor, click the Office Assistant, type "Listformat," click Search, and then click to view "Listformat Property." NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If the Assistant is not able to answer your query, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q120802 TITLE : OFFICE: How to Add/Remove a Single Office Program of ComponentFor additional information, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q173707 TITLE : OFF97: How to Run Sample Code from Knowledge Base ArticlesThis problem also occurs with bulleted lists when numbered lists are converted to bulleted lists. Although there is no continuation option for bulleted lists, a bulleted list can inherit this behavior from a numbered list. If you look at the RTF code, the same problem RTF codes immediately follow the bulleted list, although they specify "\pndec" (referring to a numbered list.)
REFERENCESRich Text Format (RTF) Specification For additional information about the Rich Text Format (RTF) Specification, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q86999 TITLE : WD: Rich Text Format (RTF) Specification 1.5 (GC0165) Keywords : appsconv kblist kbconversion Version : WINDOWS:97 Platform : WINDOWS Issue type : kbprb |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |