Call FillBookmark with image VBA Access --> Word

SkylabOne

New Member
Joined
Oct 22, 2013
Messages
21
Dear all,

Below codes fill the bookmarks in Word, no problem there. However, I'd like to add the logo of client companies to this, but I do not know how to call up images with FillBookmark based on the selected Contact.

The images are saved in the folder \logos which is in the same folder as the database and Word document.

Can someone please help with this? I'll be forever grateful!

Kind regards,
Rolf

Code:
Dim dbs As DAO.Database
Dim rst As DAO.Recordset

Set dbs = OpenDatabase(ActiveDocument.Path & "\Contacts.accdb")
'Fill recordset
Set rst = dbs.OpenRecordset("Select Company FROM Contacts;")
    
    Do While Not rst.EOF
        Me.cboContacts.AddItem rst("Company")
        rst.MoveNext
    Loop

Set rst = Nothing
Set dbs = Nothing
End Sub

Code:
Private Sub cmdInsert_Click()Dim dbs As DAO.Database
Dim rst As DAO.Recordset

If Me.cboContacts.ListIndex = -1 Then
    Beep
    MsgBox "Make a choice first", 64, "Choose from list"
    
    Exit Sub
Else

 Me.Hide
 
Set dbs = OpenDatabase(ActiveDocument.Path & "\Contacts.accdb")

Set rst = dbs.OpenRecordset("Select * FROM Contacts WHERE Company = '" & _
                            Me.cboContacts.Text & "';")
    
    Call FillBookmark("" & rst.Fields("Company"), "bmCompany")
    Call FillBookmark("" & rst.Fields("Contact_Person"), "bmContact_Person")
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Call FillBookmark("" & rst.Fields("Address"), "bmAddress")
    Call FillBookmark("" & rst.Fields("Postal") & Chr$(32) & rst.Fields("City"), "bmCity")
    Call FillBookmark("" & rst.Fields("Country"), "bmCountry")
    '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Call FillBookmark("" & rst.Fields("Phone"), "bmPhone")
    Call FillBookmark("" & rst.Fields("Email"), "bmEmail")
    
    ActiveDocument.Fields.Update
End If

    Unload Me
Set rst = Nothing
Set dbs = Nothing
End Sub
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,215,575
Messages
6,125,616
Members
449,238
Latest member
wcbyers

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top