I am extremely new to VB code and Access but I have been tasked with creating a command button within a database that holds multiple records. Each record should have the ability to export their specific data entries to a report that contains lots of formatting. I figured a .dot template with bookmarks would be the best way to get the design and function that is necessary. So far all I have found is various simple codes but every time I try to initiate the code it doesn't work. Below is what I have so far. When I click the cmd button word does not open. This database is linked through an online accessible server and I did not know if there were restrictions to what those types of databases could and couldn't do.
Sub Command516_Click()
Dim WordDoc As Word.Document
Dim WordApp As Word.Application
Dim comboID As String
Dim sn As String
Dim frb_report As String
set WordApp=Word.Application
WordApp.Visible=True
set strTemplate=Word.Document.Open("C:......Template.d ot")
Set WordDoc= WordApp.Documents.Add(Template:=strTemplate)
comboID=Forms!frmviewedit!comboID
sn=Forms!frmviewedit!sn
frb_report=Forms!frmviewedit!frb_report
Debug.Print WordDoc.Bookmarks.Count 'show test presence of bookmarks'
With WordDoc.Bookmarks
.Item("frb_id").Range.Text=comboID
.Item("serial_no0").Range.Text=sn
.Item("report_no").Range.Text=frb_report
End With
WordDoc.Save
WordDoc.close
Set WordDoc=Nothing
WordApp.Quit
Set WordApp=Nothing
End Sub