Hi,
Well, I've hit another roadblock.
I need to, from access, insert a file into an already open word document after a certain line of text. I am new to VBA and I simply don't know how to tell word where I want this document inserted. I know I should use the select method, but I am not sure what the syntax would be.
This is what I have so far:
Private Sub Command32_Click()
On Error GoTo Err_Command32_Click
Dim DocName As String
Dim WordObj As Object
Dim RptWhere As String
Dim rtp As Report
Dim SourceName As String
SourceName = "HMC" & Me.ID & ".doc"
RptWhere = "[ID] = " & Me.ID
DocName = "Article: Single Attributes"
DoCmd.OpenReport DocName, acViewPreview, , RptWhere
DoCmd.OutputTo acOutputReport, DocName, acFormatRTF, "Template.doc", True
Set WordObj = GetObject("Template.doc", "Word.Basic")
WordObj.Selection.InsertFile (SourceName)
Exit_Command32_Click:
Exit Sub
Err_Command32_Click:
MsgBox Err.Description
Resume Exit_Command32_Click
End Sub
Thank you so much for your time.
Nick
Well, I've hit another roadblock.
I need to, from access, insert a file into an already open word document after a certain line of text. I am new to VBA and I simply don't know how to tell word where I want this document inserted. I know I should use the select method, but I am not sure what the syntax would be.
This is what I have so far:
Private Sub Command32_Click()
On Error GoTo Err_Command32_Click
Dim DocName As String
Dim WordObj As Object
Dim RptWhere As String
Dim rtp As Report
Dim SourceName As String
SourceName = "HMC" & Me.ID & ".doc"
RptWhere = "[ID] = " & Me.ID
DocName = "Article: Single Attributes"
DoCmd.OpenReport DocName, acViewPreview, , RptWhere
DoCmd.OutputTo acOutputReport, DocName, acFormatRTF, "Template.doc", True
Set WordObj = GetObject("Template.doc", "Word.Basic")
WordObj.Selection.InsertFile (SourceName)
Exit_Command32_Click:
Exit Sub
Err_Command32_Click:
MsgBox Err.Description
Resume Exit_Command32_Click
End Sub
Thank you so much for your time.
Nick