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
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