E
Emma Hope
Hi All,
I want to be able to add some fields from my Access database in a Word
document. For example a very very simplified version of my Word document is
Dear AAA
Your monthly submission is BBB.
Something else, something else CCC.
effectively i want my user to press a button on an Access form and it to do
everything for them. So far i have googled and created the following:
Private Sub Command0_Click()
Dim strTemplateFile As String
Dim objWord As Object: Dim objWordDoc As Object
Set rsEmployee = CurrentDb.OpenRecordset("tblFileShortfallAnalysis")
Set objWord = CreateObject("Word.Application"): objWord.Visible = True
strTemplateFile = CurrentProject.Path & "\Introduction.doc"
Set objWordDoc = objWord.Documents.ADD
With objWordDoc
.Content.InsertFile strTemplateFile
.Content.InsertBefore & rsEmployee![Person Name] & vbCrLf & vbCrLf
.SaveAs FileName:=CurrentProject.Path & "\" & rsEmployee![Person Name]
& ".doc"
End With
End Sub
i only seem to be able to insert text at the top or the bottom, what i want
is to be able to save, move down one line, move right five characters, insert
AAA, then move down two lines and move right 27 characters, insert BBB etc.
I thought .selection.movedown Unit:=wdLine, Count:=2 etc would work but each
time i am told 'run time error 438, object doesn't support this property or
method'
Please can someone help me out and tell me what i'm doing wrong!
Thanks
Emma
I want to be able to add some fields from my Access database in a Word
document. For example a very very simplified version of my Word document is
Dear AAA
Your monthly submission is BBB.
Something else, something else CCC.
effectively i want my user to press a button on an Access form and it to do
everything for them. So far i have googled and created the following:
Private Sub Command0_Click()
Dim strTemplateFile As String
Dim objWord As Object: Dim objWordDoc As Object
Set rsEmployee = CurrentDb.OpenRecordset("tblFileShortfallAnalysis")
Set objWord = CreateObject("Word.Application"): objWord.Visible = True
strTemplateFile = CurrentProject.Path & "\Introduction.doc"
Set objWordDoc = objWord.Documents.ADD
With objWordDoc
.Content.InsertFile strTemplateFile
.Content.InsertBefore & rsEmployee![Person Name] & vbCrLf & vbCrLf
.SaveAs FileName:=CurrentProject.Path & "\" & rsEmployee![Person Name]
& ".doc"
End With
End Sub
i only seem to be able to insert text at the top or the bottom, what i want
is to be able to save, move down one line, move right five characters, insert
AAA, then move down two lines and move right 27 characters, insert BBB etc.
I thought .selection.movedown Unit:=wdLine, Count:=2 etc would work but each
time i am told 'run time error 438, object doesn't support this property or
method'
Please can someone help me out and tell me what i'm doing wrong!
Thanks
Emma