#1
|
|||
|
|||
hidden placeholder still prints
Hi, I was wondering if someone can help me. I have a Word document in that is a form for reporting test results. What I am trying to do with it, is to add in a checkbox (or button), that will indicate the type of test being carried out. Unchecked is a regular test, checked is an accredited test. When this checkbox is ticked I want a picture to show up in the header to indicate this test. I can do it via VBA, but i'm having problem when it comes to printing the document. Whether the placeholder is hidden or not, it will still print. I have attached the document in question. |
#2
|
|||
|
|||
I provided the non macro version. The code that i use is
If Application.Documents.Count > 0 Then With ActiveWindow With .View Status = .ShowPicturePlaceHolders Select Case Status Case False .ShowPicturePlaceHolders = True Case True .ShowPicturePlaceHolders = False End Select End With End With Else MsgBox "No documents open" End If |
#3
|
||||
|
||||
Create two images - one being they picture you wish to show, the other blank. Then add a bookmark where you want the image to appear, and run the following function to place the picture or the blank image in the bookmark according to the value of the checkbox. If you employ a checkbox content control you can use the CC exit even to check the value of the check box and run the function with the appropriate image for the value of the checkbox. The image will only print if it is actually displayed in the document.
Code:
Public Sub ImageToBM(strBMName As String, strImagePath As String) 'Graham Mayor - http://www.gmayor.com Dim oRng As Range Dim fso As Object Set fso = CreateObject("Scripting.FileSystemObject") If fso.FileExists(strImagePath) Then With ActiveDocument On Error GoTo lbl_Exit Set oRng = .Bookmarks(strBMName).Range oRng.Text = "" oRng.InlineShapes.AddPicture _ FileName:=strImagePath, LinkToFile:=False, _ SaveWithDocument:=True oRng.End = oRng.End + 1 oRng.Bookmarks.Add strBMName End With End If lbl_Exit: Set fso = Nothing Set oRng = Nothing Exit Sub End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#4
|
|||
|
|||
Hi gmayor,
I've created the two images, added the bookmark in the location I wish the images to appear. Is the code you provided, to be place as a macro or vba of the checkbox? I have Image 1 and Image 2 in location X:\Logo, where to I add this as an instruction for the code? |
#5
|
||||
|
||||
All you need do is change the logo's wrap format to anything other than in-line (e.g. 'in front of text') then toggle the shape's Visible property using code like:
Code:
Private Sub CheckBox1_Click() ActiveDocument.Sections.First.Headers(wdHeaderFooterPrimary).Shapes(1).Visible = Not Me.CheckBox1.Value End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#6
|
|||
|
|||
Hi macropod,
That work a brilliantly. Thanks |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Table Prints Too Small | joebeaven | Word | 6 | 02-06-2016 10:44 AM |
VBA to keep hidden rows hidden when filtering | tectonicseer | Excel Programming | 1 | 07-27-2014 11:54 AM |
Numbering labels prints | valeriab | Word VBA | 8 | 01-06-2014 06:11 AM |
SlideMaster: Date Placeholder, Footer Placeholder, Slide Number Placeholder? | tinfanide | PowerPoint | 1 | 04-05-2013 10:37 AM |
Hidden style applied over already-hidden text. | christie | Word | 1 | 08-17-2011 09:10 AM |