PDA

View Full Version : [SOLVED:] Using Hidden Text in Numbered List



Opv
12-21-2016, 10:51 AM
Is it possible to create a numbered list which automatically renumbers itself if one or more numbered paragraphs are marked as hidden text? (I am using WORD 2007.)

gmayor
12-22-2016, 12:15 AM
I am pretty sure it isn't possible, at least not as you imagine. It might be better to insert a bookmark (here "bmAddPara") at the start of the paragraph after where the additional numbered paragraph is to appear and change the content of the bookmark depending on whether you want the paragraph displayed or not. If you insert an additional paragraph, the numbering will update automatically.
You can call the function for as many bookmarks and texts as you wish.

The following macros will show or hide the text by changing the bookmark content - see https://www.youtube.com/watch?v=g29EeCm7MY4


Sub Macro1()
'Show the paragraph
FillBM "bmAddPara", "The text of the additional paragraph" & vbCr
End Sub

Sub Macro2()
'Hide the paragraph
FillBM "bmAddPara", ""
End Sub





Public Sub FillBM(strBMName As String, strValue As String)
'Graham Mayor - http://www.gmayor.com
Dim oRng As Range
With ActiveDocument
On Error GoTo lbl_Exit
Set oRng = .Bookmarks(strBMName).Range
oRng.Text = strValue
oRng.Bookmarks.Add strBMName
End With
lbl_Exit:
Set oRng = Nothing
Exit Sub
End Sub

Opv
12-22-2016, 04:11 PM
Thanks for the information and the suggestion. Much appreciated.