VBA code opens word as read only even though it's not!

C

Caroline Higson

Hi

I have VBA code assigned to a cmd button when clicked, to open Word 03
doc from Access 03:

Private Sub Help_Click()
Dim WordObj As Object
Set WordObj = CreateObject("Word.Application")
WordObj.Documents.Open "C:\Documents and Settings\Owner\My
Documents\USER GUIDE.doc"

End Sub

It worked fine for quite a while. Now however, when I click the cmd
button, nothing happens, but the "egg timer" comes up, so it must be
doing something. I then click it again and after about 10 seconds, I
can a "File is in use" box and it says that the doc is locked for
editing, gives options to read only, notify, etc. It then freezes
Access and I have to Alt Ctrl Del to stop the programs.

It is not read only from attribute, it is not proected? It says the
file is in use, but it didn't do anything the first time I clicked it?

Why has it changed all of a sudden? I have triple checked that the
document is where it is supposed to be, and when you select open as
read only, it does open the document?!

What am I doing wrong, I have battled with this for ages.

Other VBA code that I have altered based on this code is also acting
up?

Thanks for your help
 
N

Norman Yuan

The reason that the second click on the button get you a "read-only" prompt
is that the first click has already started MS Word and open the document,
however you did not see it. If you go to Task manager, you would see and
Word.exe instance is running, which has the document open. When you do
ActiveX automation this way, I'd prefer make the automated app visible, so
that user know the application being started by your Access app. If
something goes wrong, at least user can close it manually.
 

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