Open a MSWord Doc from a form

P

Pauline C

I want to open a word document from a button on a form. I
can open MS Word but can't open the file I want.
This is my code so far:

Dim oApp As Object

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

Can anyone tell me help me?

Thaning you,

Pauline
 
G

Graham Mandeno

Hi Pauline

You're on the right track. You need to add:

Dim oDoc as Object
' (or As Word.Document if you have a reference to the Word object library)

Set oDoc = oApp.Documents.Open("C:\MyFolder\MyFile.doc")

--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand

Return mail address is invalid in a vain attempt to reduce spam.
Feedback is welcome at: (e-mail address removed)
Please post new questions or followups to newsgroup.
 
P

Pauline C

That sort of worked. The Documnet I am trying to open is
a mail merge document and the first message that comes up
is that the Word document is read only as it is being used
by another user - it isn't and then it is opening a second
data base. Evenutally after clicking cancel to all
messages it does open the file - correct data and all and
I can change the document and print it but can't save it
as it is read only.
It there any way around these problems.
I really appreciate your prompt reply and being able to
get help in this way.
-----Original Message-----
Hi Pauline

You're on the right track. You need to add:

Dim oDoc as Object
' (or As Word.Document if you have a reference to the Word object library)

Set oDoc = oApp.Documents.Open("C:\MyFolder\MyFile.doc")

--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand

Return mail address is invalid in a vain attempt to reduce spam.
Feedback is welcome at: (e-mail address removed)
Please post new questions or followups to newsgroup.

Pauline C said:
I want to open a word document from a button on a form. I
can open MS Word but can't open the file I want.
This is my code so far:

Dim oApp As Object

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

Can anyone tell me help me?

Thaning you,

Pauline


.
 
G

Graham Mandeno

Hi Pauline

How are you initiating the mail merge? Are you *sure* that the document is
not already open by Word in the background? I don't know why else it would
be making you open it read-only.

The second instance of the database problem often occurs when you change the
title bar of the Access application. If DDE can't find an application
called "Microsoft Access" then it often starts up a new instance. This can
be a big problem if your database has user-based security. Then there are
the problems with filtering recordsets to merge only the records you want.

Personally, I think that mail merges direct from Access are so fraught with
pitfalls that I always export the mail merge data to a temporary text file
and use that file as the merge data source.

--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand

Return mail address is invalid in a vain attempt to reduce spam.
Feedback is welcome at: (e-mail address removed)
Please post new questions or followups to newsgroup.

Pauline C said:
That sort of worked. The Documnet I am trying to open is
a mail merge document and the first message that comes up
is that the Word document is read only as it is being used
by another user - it isn't and then it is opening a second
data base. Evenutally after clicking cancel to all
messages it does open the file - correct data and all and
I can change the document and print it but can't save it
as it is read only.
It there any way around these problems.
I really appreciate your prompt reply and being able to
get help in this way.
-----Original Message-----
Hi Pauline

You're on the right track. You need to add:

Dim oDoc as Object
' (or As Word.Document if you have a reference to the Word object library)

Set oDoc = oApp.Documents.Open("C:\MyFolder\MyFile.doc")

--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand

Return mail address is invalid in a vain attempt to reduce spam.
Feedback is welcome at: (e-mail address removed)
Please post new questions or followups to newsgroup.

Pauline C said:
I want to open a word document from a button on a form. I
can open MS Word but can't open the file I want.
This is my code so far:

Dim oApp As Object

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

Can anyone tell me help me?

Thaning you,

Pauline


.
 

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