Results 1 to 2 of 2

Thread: removing an object from memory.. please help

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Posts
    168
    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

  2. #2
    Guest
    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
  •  



Click Here to Expand Forum to Full Width