Excel wont access to MS Word from Excel using automation


Posted by adam on April 30, 2001 6:13 AM

To all:

I am trying to automate word from excel. I have got the code and it works but unfortunately sometimes it doesn't . Thats the problem plain and simple. Sometimes I get a:

Activex component cant create object when I am trying to run the beginning code to set up the word app. I have all my libraries referenced and I am using Windows NT 4.0. Can anyone help in this situation. I am sure the code works because it works sometimes. Maybe there is a workaround for this ?

I get the error on the createobject line

Thanks,

Adam

Posted by Ivan Moala on April 30, 2001 6:35 AM

Adam, I would imagine you would have something
similar to this code ??

Sub Create_WordDoc()
Dim WordObj As Word.Application
Set WordObj = CreateObject("Word.Application")
With WordObj
.WindowState = wdWindowStateMaximize
End With


What is the code you are using,it may be a case
of setting it as early binding (Above) rather then late binding......early binding versus late binding the main difference is in how you declare your variables. The following code snippet declares an object variable that refers to an instance of Microsoft Word. This example represents late binding, since we have used the generic Object data type. VBA doesn't know what type of object it is and will use late binding at run time to handle it. This is like running to the phone book before dialing the phone.

Dim wrd as Object

you could try using the [New] syntax method eg

Set WordObj = New Word.Application


HTH

Ivan



Posted by adam on May 02, 2001 7:00 AM

Ivan,

You are correct with my code. I am now getting an error that says:

RPC server is not available. Have you ever seen this ?? I took my code from a site and this error doesn't always appear but it does about half the time.

Any suggestions. ??

thanks,

Adam

HTH Ivan