-
Hello there, could (please) anyone help me with this annoying problem?
I'm making an application that has to put data on a simple Microsoft Word 2000 document. I use this code for it...
--Begin Code--
dim objWrdApp As Word.Application
On Error Resume Next
Set objWrdApp = GetObject(, "Word.Application.9")
If Err.Number = 429 Then
Set objWrdApp = CreateObject("Word.Application.9")
Err.Clear
End If
--End Code--
My application runs well until I -close- Microsoft Word myself or by code...
When I try to use the Word reference again in the same application (I didn't close it and it has ran the above declarations again), it gives me this Error message:
**********
Run-time error '462':
The remote server machine does not exist or is unavailable
**********
My application craches on all the code that uses the Word(.Global) functions, all the rest is OK.
-Begin Code-
With .ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = CentimetersToPoints(0.2) <-- CRASH!
.BottomMargin = 7.1 '0.25 cm <-- Works fine without the function...
-End Code-
I don't know what the problem is but I need a solution QUICK cause I've got to make a deadline... (AAaargh)
Can Someone help me?
Thank You for Your time!
Bart Lipkens
-
Well you're using GetObject and that's OK but then you only use CreateObject if Error 429 was raised. Change the code to this:
Code:
Dim objWrdApp As Word.Application
On Error Resume Next
Set objWrdApp = GetObject(, "Word.Application.9")
If Err.Number <> 0 Then
Err.Clear
Set objWrdApp = CreateObject("Word.Application.9")
End If
Good luck!
-
Joacim, thank You for your response, but it still doesn't work... It's just like he doesn't want to 'reinitialise' the Word reference when I've closed Word myself...
I can open Word again by code, put data in it, but when I want to use the Word(.Global) functions like the CentimetersToPoints function it just crashes, very stupid and I don't know why...
[Edited by balip on 08-30-2000 at 03:11 AM]