![]() |
#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 |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
joebeaven | Word | 6 | 02-06-2016 10:44 AM |
![]() |
tectonicseer | Excel Programming | 1 | 07-27-2014 11:54 AM |
![]() |
valeriab | Word VBA | 8 | 01-06-2014 06:11 AM |
![]() |
tinfanide | PowerPoint | 1 | 04-05-2013 10:37 AM |
![]() |
christie | Word | 1 | 08-17-2011 09:10 AM |