I'm trying to automate word; at first, with very simple code:
********
Sub automateWord()
Dim wordApp As Word.Application
' Create new hidden instance of Word.
Set wordApp = New Word.Application
' Show this instance of Word.
wordApp.Visible = True
With wordApp
' Code to automate Word here.
End With
wordApp.Quit
Set wordApp = Nothing
End Sub
************
I have set a reference to the Word Object Library.
When the code encounters the "Set" statement, I get the following error
message:
"Run-time error '-2147221231 (80040111)
Automation Error
ClassFactory cannot supply requested class"
If I substitute Excel for Word, everything works as expected.
What am I missing here?

Signature
Thank you for your help
Bill
John Nurick - 27 Aug 2005 06:52 GMT
Hi Bill,
I don't think you're missing anything. This code should work (does work
on my system). Searching groups.google.com suggests that this is an
uncommon problem caused by something having gone wrong with your Word or
Office installation. Out of curiosity I'd try
Set WordApp = CreateObject("Word.Application")
but I wouldn't expect it to work differently.
For a fix, the first thing I'd try is to re-register Word by running
winword /r
If that doesn't do the job, after that, run Office Setup and repair the
installation. After that, uninstall and re-install Office.
There's one newsgroup thread that suggests (but does not prove) a link
between this problem and Norton Antivirus 2004.
>I'm trying to automate word; at first, with very simple code:
>
[quoted text clipped - 30 lines]
>
>What am I missing here?
--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.