Hi
I've a database of audit jobs.
I'm using the code below to create a Word doc from a template and insert text and various bookmarks based on field values in an open form ("frm Recs Tracked Jobs").
Everything works well, but there is additional info in a subform ("Objectives subform") in the open form which I want to include in the Word doc also. The subform shows the objectives for each job which vary in number. I was wanting to insert the objectives at a bookmark in the Word doc above, but am unsure how to go about it. I tried creating a report and refering to that in the code, but it only inserted the first objective.
Any help would be greatly appreciated.
AL
I've a database of audit jobs.
I'm using the code below to create a Word doc from a template and insert text and various bookmarks based on field values in an open form ("frm Recs Tracked Jobs").
Everything works well, but there is additional info in a subform ("Objectives subform") in the open form which I want to include in the Word doc also. The subform shows the objectives for each job which vary in number. I was wanting to insert the objectives at a bookmark in the Word doc above, but am unsure how to go about it. I tried creating a report and refering to that in the code, but it only inserted the first objective.
Any help would be greatly appreciated.
AL
Code:
sub createdoc()
dim drname as string
drname = Forms![frm recs tracked jobs]![docfolder] & "\" & Forms![frm recs tracked jobs]![Job] & " Draft Report.doc"
Set objword = New Word.Application
With objword
.Visible = True
.Documents.Add Template:=("i:\ia manual\templates\draft report.dot")
.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
.ActiveWindow.ActivePane.View.NextHeaderFooter
.Selection.TypeText Text:=("DRAFT INTERNAL AUDIT REPORT - " & Forms![frm recs tracked jobs]![Job])
.ActiveWindow.ActivePane.View.NextHeaderFooter
.Selection.TypeText Text:=("DRAFT INTERNAL AUDIT REPORT - " & Forms![frm recs tracked jobs]![Job])
.Selection.Goto Name:=("Audit1")
.Selection.TypeText Text:=(Forms![frm recs tracked jobs]![Job])
.Selection.Goto Name:=("Audit2")
.Selection.TypeText Text:=(Forms![frm recs tracked jobs]![Job])
.Selection.Goto Name:=("Audit4")
.Selection.TypeText Text:=(Forms![frm recs tracked jobs]![Job])
.Selection.Goto Name:=("department")
.Selection.TypeText Text:=(Forms![frm recs tracked jobs]![DepartmentName])
.Selection.Goto Name:=("assurancelevel")
.Selection.TypeText Text:=(Forms![frm recs tracked jobs]![Assurance DR])
.ActiveDocument.SaveAs (drname)
.Quit
End With
End Sub