how to reshow userform after following a link

K

Ken

I have a userform (first tier) that calls another userform (second
tier), and the second tier userform has code associated with a
combobox that opens a link to another excel file in a new window.
After the the linked file is closed, I would like to return to the
calling userform (second tier) and have both the first tier and second
tier userforms again visible. I had it set up so that the hidden
userforms were reshown by the WorkBookActivate event code; that seemed
to work okay since the initial workbook became the active workbook
when the temporarily viewed worksheet was closed. But, I ran into a
problem with putting the code there, as that code runs too often for
me. Sometimes, when that workbook becomes the active workbook I don't
want the userforms to be displayed.

The sequence of events is basically:

display form1
display form 2

follow link to another excel file (but I don't see it if I don't hide
the two forms)

hide form2
hide form1

Exit sub

close linked file

return to initial workbook, but, forms are no longer visible; and I
want them to be restored automatically

Is there a way to reshow the forms after the linked file is closed? I
have not been able to use the WorkbookActivate event and I prefer not
to have to have any code in the linked files. I am hoping to have
something in the code like "be right back", and having it pick up
there, after the linked file is closed.

Thanks

Ken
 
G

GS

Try checking to see if the userforms are loaded before unhiding.

In the Workbook_Activate event:
If Not Userform1 Is Nothing Then Userform1.Show
If Not Userform2 Is Nothing Then Userform2.Show

This precludes that when the userforms aren't needed then they get
unloaded. This way, the code will unhide the userforms only when
they're loaded.
 

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

Top