Word 8.0 and VB 5.0: object variable destroyed after closing word 
Author Message
 Word 8.0 and VB 5.0: object variable destroyed after closing word

We are launching Winword 97 from within VB5 by using OLE automation.

Wehenever we use the WithEvents statement in the Var-definition, we
can't reuse the Word Object variable after we do a WordObj.Quit.

NT4+SP3/ VB5-SP3, Word97 German, SR1

A workaround by sending messages from Word-macros is not appreciated. To
declare the object variable local too.

Code fragments:
Private WithEvents aplword As Word.Application

Sub StartWord()
Set aplword = New Word.Application
aplword.Visible = True
End Sub

Sub StopWord()
aplword.Application.Quit 'This line seems to render the object var
unusable Set aplword = Nothing  ' -->Bang end sub
End Sub

The same problem occurs with Word.Document.

Is there any other chance??

Thanks in advance,
Claudia Traunfellner



Sun, 17 Sep 2000 03:00:00 GMT  
 Word 8.0 and VB 5.0: object variable destroyed after closing word

Hi Claudia,

You are right.  Those variables are unstable especially when using dim
withevents.  There are bugs in the word 8.0 withevents.

What I do as a workaround is do use getobject("","Word.Application")
and keep this copy around FOREVER until my application exits.  Notice
that the "" (Null string) is different from the missing first
parameter.

Hope this helps,
Kurt

On Wed, 1 Apr 1998 18:03:07 +0200, "Claudia Traunfellner"

Quote:

>We are launching Winword 97 from within VB5 by using OLE automation.

>Wehenever we use the WithEvents statement in the Var-definition, we
>can't reuse the Word Object variable after we do a WordObj.Quit.

>NT4+SP3/ VB5-SP3, Word97 German, SR1

>A workaround by sending messages from Word-macros is not appreciated. To
>declare the object variable local too.

>Code fragments:
>Private WithEvents aplword As Word.Application

>Sub StartWord()
>Set aplword = New Word.Application
>aplword.Visible = True
>End Sub

>Sub StopWord()
>aplword.Application.Quit 'This line seems to render the object var
>unusable Set aplword = Nothing  ' -->Bang end sub
>End Sub

>The same problem occurs with Word.Document.

>Is there any other chance??

>Thanks in advance,
>Claudia Traunfellner



Mon, 18 Sep 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Word 97 - Closing Word Outside App kills object reference

2. Print a Word document from VB and then Close Word

3. microsoft word 8.0 object library

4. Microsoft Word 8.0 Object Library

5. Object Library für Word Perfect 8.0 in vba

6. Microsoft Word 8.0 Object Library

7. MS Word 9.0 vs. 8.0 Object Library

8. Word 8.0 Object ***Help***

9. accessing word document through vb.net using word com object

10. Setting an object variable to Nothing does not destroy the object

11. Using CRW 4.6 /VB 5.0 to report Oracle 8.0 object table data

12. VB 5.0 - Error:91 Object Variable Or With Block Variable Not Set

 

 
Powered by phpBB® Forum Software