|
-
Apr 17th, 2000, 05:11 AM
#1
Thread Starter
Addicted Member
hello.. how do you remove something from memory?.. example
Code:
DIM MSWORD AS New Word.Application
Word.Documents.Add 'This adds a document to the memory.
Even after I do Word.Documents.Close and SET Word = Nothing, the task manager still shows it exists and after I run the routine a few times I get memory problems. How do I remove it?
Thanks,
Thai
-
Apr 17th, 2000, 05:43 AM
#2
This little test seemed to work, start a new Standard EXE, cut and paste the following code, set a Reference the the Word Library, and press F5. It should open up ten documents and then displays the count in a msgbox in the VBIDE. Just close the form, upon exiting it will try to kill each individual document and then will continue setting the word app object var to nothing until it is actually nothing.
Code:
Option Explicit
Dim wdApp As Word.Application
Dim intCount As Integer
Private Sub Form_Load()
Set wdApp = New Word.Application
For intCount = 1 To 10
wdApp.Documents.Add
Next
wdApp.Visible = True
MsgBox wdApp.Documents.Count
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim objDoc As Word.Document
On Error Resume Next
If Not wdApp Is Nothing Then
For Each objDoc In wdApp.Documents
objDoc.Close False
Next
End If
wdApp.Quit
Do Until wdApp Is Nothing
Debug.Print "Die Word Die!"
Set wdApp = Nothing
Loop
End Sub
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
|