Multiple forms

  • Thread starter Thread starter Helen Trim
  • Start date Start date
H

Helen Trim

I have an application with three forms that are msde
visible and activated when needed. It uses Word to open
documents and one of the forms is opened as the Word
document is closed in the DocumentBeforeClose event. It
works the first time but when it makes the form visible
for the second time, it freezes. Sometimes it gives an
out of memory error, but I think that may be a red herring.

Any ideas? Has anyone come across similar problems?

Should I be creating new instances of forms each time they
are needed, rather than having one instance of each and
showing and hiding them?

Thanks
Helen
 
Are these forms being shown using 'Show' or 'ShowDialog'?

My guess is that when the form are invisible, you are using Form1.Show...
and not Form1.Visible = True, but cannot be sure as you haven't added any
code in your original post.

If you are using 'Show' & not 'Visible' then you probably have multiple
instances of the forms.

The other thing it cold be is that you are not destroying the MS Word
object. That can be proved by looking for multiple instances of 'Winword.Exe'
in Task Manager

Paste some code for a proper solution though.
 
I have an instance of each form that I make visible using
the visible property and activate when needed, as you
suggest.

Word is quit and set to nothing each time, and that works
with no problem.

Example:
Public Saving As New frmSaving

Private Sub WordApp_DocumentBeforeClose
Doc.Close()
Saving.Visible = True
Saving.Activate()
WordApp.Application.Quit()
WordApp = Nothing

This works perfectly the first time it is used, then
freezes the second time on the Saving.Visible = True line.

There isn't an obvious reason why. I would be really
grateful for any ideas you can give me.

Thanks
Helen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top