N
naigy via AccessMonster.com
Hi I have a word document which is used as a template for parts used on a
repair for a particular unit. This template has a table in it. I need to
export a query into this table in this word template to comply with company
policy. As such I have tried various code on different websites to do this
but they all seem to export the data into the one cell in this table
(including queryname and column headings which I don't want. The way I am
referencing the table in word is using a bookmark in the first cell on the
2nd row. The first row of the table is used for headings but these do not
match the field names of the related data in my database. Below is the code I
am currently using. Your assistance would be appreciated. Please note I did
post a query for this info on another site around a week ago and did not get
a response hence the reason I am requesting help here. The site was
http://www.dbforums.com/showthread.php?t=1212107 if you would like to check
before replying. Once again thanks for any assistance.
Private Sub Command62_Click()
On Error GoTo Err_Command62_Click
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim PathDocu As String
Set oWord = CreateObject("Word.Application")
PathDocu = CurrentProject.Path
Set oDoc = oWord.Documents.Open(PathDocu & "\Writeoff.dot")
oWord.Visible = True
DoCmd.OpenQuery ("QWriteOffSummary")
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdCopy
oDoc.Bookmarks("wot").Range.Paste
Exit Sub
Err_Command62_Click:
MsgBox "Error Printing Writeoff Request Form"
End Sub
repair for a particular unit. This template has a table in it. I need to
export a query into this table in this word template to comply with company
policy. As such I have tried various code on different websites to do this
but they all seem to export the data into the one cell in this table
(including queryname and column headings which I don't want. The way I am
referencing the table in word is using a bookmark in the first cell on the
2nd row. The first row of the table is used for headings but these do not
match the field names of the related data in my database. Below is the code I
am currently using. Your assistance would be appreciated. Please note I did
post a query for this info on another site around a week ago and did not get
a response hence the reason I am requesting help here. The site was
http://www.dbforums.com/showthread.php?t=1212107 if you would like to check
before replying. Once again thanks for any assistance.
Private Sub Command62_Click()
On Error GoTo Err_Command62_Click
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim PathDocu As String
Set oWord = CreateObject("Word.Application")
PathDocu = CurrentProject.Path
Set oDoc = oWord.Documents.Open(PathDocu & "\Writeoff.dot")
oWord.Visible = True
DoCmd.OpenQuery ("QWriteOffSummary")
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdCopy
oDoc.Bookmarks("wot").Range.Paste
Exit Sub
Err_Command62_Click:
MsgBox "Error Printing Writeoff Request Form"
End Sub