Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime error 429

Status
Not open for further replies.

newbee2

Technical User
Apr 21, 2002
85
0
0
Hi,
The following code gives me the run time error 429. Active X can't create object.
I am atuomating from Excel 2000.

'create a word instance if there isn't one
'or use an existing instance if there is one in use
Set objWord = GetObject(, "Word.Application")
If Err.Number <> 0 Then
'Word not running, create new Instance
Set objWord = CreateObject(&quot;Word.Application&quot;)
objWord.Visible = True
End If

And also Runtime 4601 cant activate application.
If intReturn = vbNo Then
objDoc.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
GoTo WordstartExit

I have referneced the following
Visual basic for apps
Microsoft excel 9
ole automation
office 9
forms 2
access 9
word 9

Any Suggestions
Regards
Bill
 
I suspect it's your &quot;If&quot; statement - try something like this:

On Error Goto ErrorHandler:

Set objWord = GetObject(, &quot;Word.Application&quot;)
objWord.Visible = True

ErrorHandler:

select case Err.number
Case 0
'ignore
Case 429
set objWord = CreateObject(&quot;Word.Application&quot;)
objWord.Visible = True
resume
Case Else
err.clear
Resume Next
End select

Also I think you will have to reference libraries such as the &quot;Microsoft ActiveX Data Objects 2.5 Library&quot; and/or &quot;Microsoft ActiveX Data Objects Recordset 2.5 Library&quot;

With regards to your error 4601 problem I think it's because you are in Excel and the document isn't &quot;active&quot; as it were, Excel is. You'll have to add an line that activates the document first so that it has the object to close.

(Maybe like this but you'll have to check)
objWord.document(name?).activate
objword.activedocument.close
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top