I want to insert a small graphic image into a a book mark query I prepare in access (1 Viewer)

atrium

Registered User.
Local time
Tomorrow, 08:10
Joined
May 13, 2014
Messages
348
I have a series of Yes/No fields in a table and I need to insert a tick box image either on or off and merged into a word document performed in access.

This is what I started with but soon realised it want work - any ideas on how I can do it PLEASE


Code:
 IIf([PAYGOT]=True,[tickBox15x14.jpg],[blankTickBox15x14.jpg])
 
Last edited:

atrium

Registered User.
Local time
Tomorrow, 08:10
Joined
May 13, 2014
Messages
348
This is the code I have created to move the image in to the bookmark position.


Code:
        If oWordDoc.Bookmarks.Exists("BM157") = True Then
                  Set Rng = oWordDoc.Bookmarks("BM157").Range
                  Rng.Collapse
                  If strBookmarkValue = -1 Then
                     sImageFilename = "tickBox15x14.jpg"
                  Else
                     sImageFilename = "blankTickBox15x14.jpg"
                  End If
                  Set shp = oWordDoc.InlineShapes.AddPicture(FileName:=sImagesPath & "\" & sImageFilename, SaveWithDocument:=True, Range:=Rng).ConvertToShape
                  With shp
                    .LockAspectRatio = True
                    .left = 0  'CentimetersToPoints(0)
                    .Top = 0   'CentimetersToPoints(0)
                    .width = 15    'CentimetersToPoints(2.5)
                    .WrapFormat.Type = wdWrapFront
                  End With
           End If

I get an error 13 type mismatch error on the 2nd line. The Merge has gone through and it's now looking at putting in the images.
BM157 = -1

Can anyone tell me why I get an error on the Set Rng = oWordDoc.Bookmarks("BM157").Range
 
Last edited:

strive4peace

AWF VIP
Local time
Today, 17:10
Joined
Apr 3, 2020
Messages
1,003
hi @atrium

how is Rng declared?

Where and what is your Dim statement?

it should be something like this:
Rich (BB code):
Dim Rng As Range  'Object if late-binding
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 17:10
Joined
Feb 28, 2001
Messages
27,146
Instead of looking for an image to insert, look into making a small text box with WingDings2 font, using character 0x050. That's a check box. You can scale it by changing font size and can place it using centering, both horizontal and vertical.
 

strive4peace

AWF VIP
Local time
Today, 17:10
Joined
Apr 3, 2020
Messages
1,003
adding on ... you can use Unicode, and then you don't even have to change the font

Rich (BB code):
   Rng.Text = ChrW(9744)  'Checkbox open ☐
   Rng.Text = ChrW(9745)  'Checkbox checked ☑
   Rng.Text = ChrW(9746)  'Checkbox checked ☒ 

and, in that case, you don't need a range object either!

Rich (BB code):
oWordDoc.Bookmarks("BM157").Range.Text = ChrW(9745)
 
Last edited:

strive4peace

AWF VIP
Local time
Today, 17:10
Joined
Apr 3, 2020
Messages
1,003
and, you could probably skip the bookmarks too! Just search and replace 0 and -1 ...

Rich (BB code):
Sub ReplaceWithCheckboxes() 
   With ActiveDocument.Range.Find 
      .Text =  "0"
      .Replacement.Text = ChrW(9744) 
      .MatchWholeWord = True 
      .Execute Replace:=2   'wdReplaceAll
      .Text =  "-1"
      .Replacement.Text = ChrW(9745) 
      .MatchWholeWord = True 
      .Execute Replace:=2   'wdReplaceAll
   End With 
   MsgBox  "done"
End Sub

It wouldn't have to be the whole document -- but that might work for you ;)
 
Last edited:

atrium

Registered User.
Local time
Tomorrow, 08:10
Joined
May 13, 2014
Messages
348
Thank you everyone for your input, much appreciated.
I have used strive4peace's idea. It does exactly what I need
 

Users who are viewing this thread

Top Bottom