Log in

View Full Version : Printing shows hidden rich text elements



Timotheus142
02-21-2017, 07:14 PM
Hey guys,

I´m currently having a small problem: I´m working on a really big document with hundreds of bookmarks and input fields to enter + hide and show different elements. I´m simply hiding/showing by


ActiveDocument.Bookmarks("X10").Range.Font.Hidden = Not CheckBox2a.Value

The problem I have is: If I print the document (Doesnt matter if by vba -see below- or word itself), the hidden rich text elements (that are bookmarks aswell to allow only certain inputs) get shown again and remain in the document. I just can´t move em out, even if I execute the actualization in the same step as the printing (actualization works fine and all not-used fields are removed.). Document looks fine excpet after printing...

Unspectacular printing VBA without the actualization calls (which are all similar to the method shown above):


Private Sub CommandButton11_Click()
If ActiveDocument.Bookmarks("Ma3").Empty = True Then
ActiveDocument.Bookmarks("Ma3B").Range.Font.Hidden = True
End If

If ActiveDocument.Bookmarks("Ma3").Range = " " Then
ActiveDocument.Bookmarks("Ma3B").Range.Font.Hidden = True
End If

If ActiveDocument.Bookmarks("Ma3").Range <> " " Then
ActiveDocument.Bookmarks("Ma3B").Range.Font.Hidden = False
End If

Application.PrintOut FileName:="", Copies:=1, Range:=wdPrintRangeOfPages, Pages:="p1s2-p15s10"
End Sub

I´m still kinda new to VBA and so far I couldn´t find a working method to change the printing process so much that it does not show the hidden elements again. Maybe any idea? Help appreciated!

Small visual example of what´s going on: (2/3/4 etc. should be hidden and are hidden until I click print or save as PDF)

18439

All the best!

gmaxey
02-21-2017, 07:25 PM
What are you trying to do? If you bookmark Ma3 has no content then Ma3B is hidden by the first If ... End If and then shown again by the third If ... End If.

Timotheus142
02-21-2017, 07:47 PM
What are you trying to do? If you bookmark Ma3 has no content then Ma3B is hidden by the first If ... End If and then shown again by the third If ... End If.

For these bookmarks there is a difference between the empty bookmark and one with a space in them. But they are not part of the problem anyway, I think. Just wanted to show that I´m using the standard PrintOut method.

I am hiding paragraphs of the text, and if one of the bookmarks that is open for user input is included in a hidden paragraph, it reappears after print/save as PDF.

Paul_Hossler
02-22-2017, 11:55 AM
What are your settings for



ActiveWindow.View.ShowHiddenText = True
Options.PrintHiddenText = True


18443

Timotheus142
02-22-2017, 02:22 PM
What are your settings for



ActiveWindow.View.ShowHiddenText = True
Options.PrintHiddenText = True




Both are false. All hidden text is correctly hidden by printing except for hidden rich text elements with content (not empty).