D
David
I've inherited several hundred small documents that have a couple of
templates attached to them to carry out specific tasks.
One of these templates prepares the document for printing, which means
that the document history section is deleted. Unfortunately, due to
human error a print ready document has been saved which means that the
document history is lost.
Easy, the solution is to hide the content of the document history
section when printing. However, this is complicated by a table that
captures information like author, date modified, document path,
template version used, etc. of which some of the information is already
hidden.
So I've written a macro that hides the document history section and
then, because hide is a toggle, hides the text that had become
unhidden. I've also tried revealing the hidden text and then hiding the
section, but I keep getting the same result.
After the macro completes the table borders of the text that was hidden
before the macro ran are still left in place, which is undesirable.
I've tried the process manually, by stopping the macro then doing
Format | Font | Hide, which works perfectly.
Can anyone help identify why the table borders are still showing when
the following macro runs?
Sub UpdateDocProperties()
' Define the range for the following macro
Dim docRange As Range
Set docRange = ActiveDocument.Bookmarks("DocControl").Range
' Go to the start of the document
Selection.HomeKey Unit:=wdStory
' Message box so that I know what's happening
MsgBox ("Hiding all text")
' Hide the text in DocControl section
docRange.Font.Hidden = True
' Message box so that I know what's happening
MsgBox ("Hide template text")
' Hide the text that has been revealed
With docRange.Find
.Font.Hidden = False ' find hidden text
.Style = "CharAuthorFlags" ' make sure that it's the right
style
.Wrap = wdFindStop
.Replacement.Font.Hidden = True
.Execute Replace:=wdReplaceAll
End With
End Sub
templates attached to them to carry out specific tasks.
One of these templates prepares the document for printing, which means
that the document history section is deleted. Unfortunately, due to
human error a print ready document has been saved which means that the
document history is lost.
Easy, the solution is to hide the content of the document history
section when printing. However, this is complicated by a table that
captures information like author, date modified, document path,
template version used, etc. of which some of the information is already
hidden.
So I've written a macro that hides the document history section and
then, because hide is a toggle, hides the text that had become
unhidden. I've also tried revealing the hidden text and then hiding the
section, but I keep getting the same result.
After the macro completes the table borders of the text that was hidden
before the macro ran are still left in place, which is undesirable.
I've tried the process manually, by stopping the macro then doing
Format | Font | Hide, which works perfectly.
Can anyone help identify why the table borders are still showing when
the following macro runs?
Sub UpdateDocProperties()
' Define the range for the following macro
Dim docRange As Range
Set docRange = ActiveDocument.Bookmarks("DocControl").Range
' Go to the start of the document
Selection.HomeKey Unit:=wdStory
' Message box so that I know what's happening
MsgBox ("Hiding all text")
' Hide the text in DocControl section
docRange.Font.Hidden = True
' Message box so that I know what's happening
MsgBox ("Hide template text")
' Hide the text that has been revealed
With docRange.Find
.Font.Hidden = False ' find hidden text
.Style = "CharAuthorFlags" ' make sure that it's the right
style
.Wrap = wdFindStop
.Replacement.Font.Hidden = True
.Execute Replace:=wdReplaceAll
End With
End Sub