T
Tahseena Ishrat Ahmed
Dear Group
I have opened a word template file in access 97.
My Word version is word 2003.
I want to open a rtf file or a doc file in this template.
The code is listed below. Please give me a solution how to do that.
Function Open_WordDoc()
On Error GoTo Err_Open_WordDoc
Dim doc As Object
Dim wrdApp As Object
Dim DocPath As String
DocPath = "H:\DocumentTemplate.dot"
DoCmd.OutputTo acOutputReport, "ReportTest", acFormatRTF,
"H:\ReportTest.rtf", False
Set wrdApp = GetObject(, "word.application")
On Error Resume Next
With wrdApp
Set doc = .Documents.Add(Template:=DocPath, NewTemplate:=False,
DocumentType:=0)
.Documents.Open "H:\ReportTest.rtf"
End With
wrdApp.Visible = True
wrdApp.Activate
doc.Activate
Exit_Open_WordDoc:
Set doc = Nothing
Set wrdApp = Nothing
Exit Function
Err_Open_WordDoc:
MsgBox Err.Description
Set wrdApp = CreateObject("Word.Applicatipon")
Resume Next
End Function
I have opened a word template file in access 97.
My Word version is word 2003.
I want to open a rtf file or a doc file in this template.
The code is listed below. Please give me a solution how to do that.
Function Open_WordDoc()
On Error GoTo Err_Open_WordDoc
Dim doc As Object
Dim wrdApp As Object
Dim DocPath As String
DocPath = "H:\DocumentTemplate.dot"
DoCmd.OutputTo acOutputReport, "ReportTest", acFormatRTF,
"H:\ReportTest.rtf", False
Set wrdApp = GetObject(, "word.application")
On Error Resume Next
With wrdApp
Set doc = .Documents.Add(Template:=DocPath, NewTemplate:=False,
DocumentType:=0)
.Documents.Open "H:\ReportTest.rtf"
End With
wrdApp.Visible = True
wrdApp.Activate
doc.Activate
Exit_Open_WordDoc:
Set doc = Nothing
Set wrdApp = Nothing
Exit Function
Err_Open_WordDoc:
MsgBox Err.Description
Set wrdApp = CreateObject("Word.Applicatipon")
Resume Next
End Function