Excel macro to open Word document (Macintosh)

T

Tim Golobic

Surely there is a simple solution for this, but my macro skills are
getting rusty.

Trying to open a Word document via an Excel macro. This is on a
Macintosh so the ActiveX solutions I have seen do not work. The Word
file then has its own AutoRun to take it from there.

Thanks

Tim
 
T

Tim Golobic

Surely there is a simple solution for this, but my macro skills are
getting rusty.

Trying to open a Word document via an Excel macro. This is on a
Macintosh so the ActiveX solutions I have seen do not work. The Word
file then has its own AutoRun to take it from there.

Thanks

Tim

To further clarify, that is to open the Word doc in Word using an
Excel macro, not to open the Word doc in Excel.
 
B

Bob Greenblatt

To further clarify, that is to open the Word doc in Word using an
Excel macro, not to open the Word doc in Excel.
Try the following code

Dim oWord as object
On error resume next
Err.number=0
Set oword=getobject(,"Word.Application")
If err.number<>0 then set oword=create.object("Word.Application")
Err.clear

oword.documents.add fullpath:document.doc
 
T

Tim Golobic

Try the following code

Dim oWord as object
On error resume next
Err.number=0
Set oword=getobject(,"Word.Application")
If err.number<>0 then set oword=create.object("Word.Application")
Err.clear

oword.documents.add fullpath:document.doc


Bob -

Huge help, thank you. I did need to change the ".add" to ".open". It
appears ".add" looks for a template.

However, everything was working great, no problems. Then all of a
sudden after a little more testing I now get "Run-time error 429
ActiveX component cannot create object" on the command:
Set oWord = GetObject(, "Word.Application")"

I had to disable the On Error to find this.

Any thoughts?

Tim
 
B

Bob Greenblatt

Bob -

Huge help, thank you. I did need to change the ".add" to ".open". It
appears ".add" looks for a template.

However, everything was working great, no problems. Then all of a
sudden after a little more testing I now get "Run-time error 429
ActiveX component cannot create object" on the command:
Set oWord = GetObject(, "Word.Application")"

I had to disable the On Error to find this.

Any thoughts?

Tim
Yeah, is WORD running? That code with the error detection is supposed to
create the WORD object whether or not WORD is already loaded.
 
T

Tim Golobic

Yeah, is WORD running? That code with the error detection is supposed to
create the WORD object whether or not WORD is already loaded.

I had thought of that and tried it with Word both running and not.
Then of course, it mysteriously started working again, then stopped
again. Alas ...

Tim
 

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