VBA - Automating Word from Excel

T

Tedsec

I am working on a project where I need word and excel to talk to each
other. I don't know if this should go in the Word users group or the
Excel users group, so I will post it in both (I'm new to users groups,
so it that is against the "users group etiquette" let me know)

I have been successful at automating Excel from Word, and that code
seems to work just fine. However, I now have an excel spreadsheet that
needs to talk to a word document. Everytime I try to create a new
Word.Application object, I get the dreaded "Run-time error 429: ActiveX
object can't create object." here is my code:

Sub Test()

Dim wApp As Object
Dim wDoc As Object

Set wApp = CreateObject("Word.Application")
Set wDoc = wdApp.Documents.Add

wApp.Application.Dialogs(wdDialogFileOpen).Show
Set wDoc = wApp.Documents(1)

wDoc.Range(Start:=0).Select
wDoc.Application.Selection.TypeText ("this is a test")

wDoc.Save
wDoc.Close

End Sub

The error happens on the Set wApp = CreateObject line. I've also tried
wApp = new Word.Application with the same results. I also opened Tools
References and made sure that "Microsoft Word 11.0 Object Library"
has been checked.

All of the help files I can find on the internet deal with editing
registry keys and other PC only activities. I'm running Panther 10.2.8
and I am using Microsoft Office 2004. Does anyone know why this error
might be coming up? Why is it that I can automate excel from within
word, but when I try to automate word from excel, I get this error?

Thanks in advance.
 
J

JE McGimpsey

Tedsec said:
I don't know if this should go in the Word users group or the
Excel users group, so I will post it in both (I'm new to users groups,
so it that is against the "users group etiquette" let me know)

Generally, it's better to "cross-post", which means including the names
of both groups in the "To:" or "Newsgroups:" header. That way only one
copy is sent to the server, and replies are seen in both groups.

See my answer in m.p.m.o.excel.
 

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