about opening a word template in MS Access 97

  • Thread starter Tahseena Ishrat Ahmed
  • Start date
T

Tahseena Ishrat Ahmed

Dear Group

I can open Word from Access using the following expression.

Dim mobjWordApp As Object

Set mobjWordApp = CreateObject("Word.Application")
mobjWordApp.Visible = True

But I want to open a Word Template ( .dot) that I created.

Can I get any help about it?
My Access version is Access 97
 
T

Tahseena Ishrat Ahmed

Dear Group

My question was not complete. In Ms Access 97, I want ot open a Word
Template, that I created. But the actual purpose is I want to open a report
in Word, which I can do using DoCmd.OutputTo Command to a RTF file.

Can I open this RTF file to this Template file?
 
T

Tahseena Ishrat Ahmed

Dear Group

I am trying with the following code to open a word template at first and
then to open a rtf file, or doc file in it. But my problem is whenever I try
to execute this code, I get an error in the line marked '*******

Please give me a solution. I cannot proceed with this code to open the rtf
file, because before executing that line it is showing error. My code is


Function Open_WordDoc()
On Error GoTo Err_Open_WordDoc

Dim oApp As Object
Dim doc As Object
Dim wrdApp As Object
Dim DocPath As String

DocPath = "H:\Document_Heading.dot"

Set wrdApp = CreateObject("word.application")
Set doc = wrdApp.Documents.Add(DocPath) '****** showing Errror in this line

'doc.OpenDataSource Name:="H:\QUOTE_REPORT.rtf"

wrdApp.Visible = True

Exit_Open_WordDoc:
Exit Function

Err_Open_WordDoc:

MsgBox Err.Description
Resume Exit_Open_WordDoc

End Function



Private Sub Command1_Click()

Call Open_WordDoc

End Sub
 
T

Tahseena Ishrat Ahmed

Dear Group

I have another problem. In access 97, if I want to declare a variable named

Dim appWord As Word.Application or
Dim docs As Word.Documents

I get compilation error: User defined type not defined

Do you think, I should select something in Reference, I have already select
Microsoft Office 11.0 Object Library, but it still showing the same
compilation error.

Please solve my problems.
 
T

Tom Wickerath

I'm sorry, but what is it that you don't understand???
You've apparently got two lines of code repeated below, that are considered
early bound code (actually, you added the word "or" on the end of the first
line, but I'll assume that was a typo):

Dim appWord As Word.Application
Dim docs As Word.Documents


This code requires a checked reference to the "Microsoft Word x.x Object
Library", where x.x represents the version number (sounds like it might be
11.0 in your case, so I'm assuming you have Office 2003 without Access
installed, plus your older copy of Access from Office 97.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

:

I do not understant your solution.


--
Regards

Tahseena Ishrat Ahmed
__________________________________________

:

You need to select the Microsoft Word {version} Object Library, if you are
going to use early bound code. You may not even need the reference that you
have added for the Office Object Library.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

:

Dear Group

I have another problem. In access 97, if I want to declare a variable named

Dim appWord As Word.Application or
Dim docs As Word.Documents

I get compilation error: User defined type not defined

Do you think, I should select something in Reference, I have already select
Microsoft Office 11.0 Object Library, but it still showing the same
compilation error.

Please solve my problems.
 
T

Tahseena Ishrat Ahmed

Dear Tom

I added as reference

Microsoft Office 11.0 Object and

OLE Automation

But still it does not work. Please suggest me a solution.
 
T

Tom Wickerath

Tahseena,
I added as reference
Microsoft Office 11.0 Object and
OLE Automation
But still it does not work. Please suggest me a solution.

I'm not surprised at your result. Are you? I've already given you the
correct solution, but for whatever reason, you seem to be refusing to
implement it. Go back and re-read what I have written thus far.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top