|
-
Jul 9th, 2002, 05:26 AM
#1
Thread Starter
New Member
OLE Ms Word
Hello,
I have started programming vb6 about a month ago and i have runin to a little bit of a problem. I want to open Ms Word with a new document and setup this document through my vb6 program. The first time vb6 opens Ms Word there is are no errors and Word is started, but when Ms Word is closed and i run the code for the second time i get this error message:
RUN TIME ERROR the remote machine does not exits or is unavailable.
Thanx for your time !,
This is the code:
Public objWord As Word.Application
Private Sub cmdStart_Click()
Dim range1 As Range
Dim DocNaam As String
Dim DezeDoc As Document
Set objWord = new Word.Application
objWord.Visible=True
With objWord
.documents.Add
DocNaam = .ActiveDocument.Name
set DezeDoc = .Documents(DocNaam)
set range1 = DezeDoc.Range
range1.InsertAfter "test"
range1.PageSetup.Topmargin = CentimetersToPoints (3.5)
End With
End Sub
-
Jul 9th, 2002, 06:08 AM
#2
Hi kabouter do some exercises and you won't be that stram any more.
I think it should be better to close the word application when the form using it is unloaded.
And set the object with an instance of it to nothing.
-
Jul 9th, 2002, 09:38 PM
#3
Lively Member
doent look like you closed msword either, if you open it than you have to close it and destroy the object, (from reply above me)
Don't go away mad, just go away.
Bam-Bam
-
Jul 29th, 2002, 04:45 AM
#4
Addicted Member
Hi,
Quit the instance of the word u are using as shown below to avoid the error.
'------------------------------------------------------------------------------
objWord.Quit
Set objword = Nothing
----------------------------------------------------------------------------------
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|