Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-15-2016, 05:33 AM
estrangedred estrangedred is offline hidden placeholder still prints Windows 7 64bit hidden placeholder still prints Office 2010 32bit
Novice
hidden placeholder still prints
 
Join Date: Dec 2016
Posts: 5
estrangedred is on a distinguished road
Default 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.
Attached Files
File Type: docm QS00093.docm (205.4 KB, 9 views)
Reply With Quote
  #2  
Old 12-15-2016, 07:16 AM
estrangedred estrangedred is offline hidden placeholder still prints Windows 7 64bit hidden placeholder still prints Office 2010 32bit
Novice
hidden placeholder still prints
 
Join Date: Dec 2016
Posts: 5
estrangedred is on a distinguished road
Default

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
Reply With Quote
  #3  
Old 12-15-2016, 07:22 AM
gmayor's Avatar
gmayor gmayor is offline hidden placeholder still prints Windows 10 hidden placeholder still prints Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #4  
Old 12-15-2016, 07:43 AM
estrangedred estrangedred is offline hidden placeholder still prints Windows 7 64bit hidden placeholder still prints Office 2010 32bit
Novice
hidden placeholder still prints
 
Join Date: Dec 2016
Posts: 5
estrangedred is on a distinguished road
Default

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?
Reply With Quote
  #5  
Old 12-15-2016, 03:55 PM
macropod's Avatar
macropod macropod is offline hidden placeholder still prints Windows 7 64bit hidden placeholder still prints Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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
including or omitting the 'Not' according to which checkbox state the visibility is to reflect.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 12-16-2016, 03:20 AM
estrangedred estrangedred is offline hidden placeholder still prints Windows 7 64bit hidden placeholder still prints Office 2010 32bit
Novice
hidden placeholder still prints
 
Join Date: Dec 2016
Posts: 5
estrangedred is on a distinguished road
Smile

Hi macropod,

That work a brilliantly. Thanks
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
hidden placeholder still prints Table Prints Too Small joebeaven Word 6 02-06-2016 10:44 AM
hidden placeholder still prints VBA to keep hidden rows hidden when filtering tectonicseer Excel Programming 1 07-27-2014 11:54 AM
hidden placeholder still prints Numbering labels prints valeriab Word VBA 8 01-06-2014 06:11 AM
hidden placeholder still prints SlideMaster: Date Placeholder, Footer Placeholder, Slide Number Placeholder? tinfanide PowerPoint 1 04-05-2013 10:37 AM
hidden placeholder still prints Hidden style applied over already-hidden text. christie Word 1 08-17-2011 09:10 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:07 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft