Finding Current UserForm

P

PRegis08

How would I find the name of the current or active userform?

I have a presentation done completely with userforms in the VBA section of
PowerPoint. I have a common link that would require the current active
userform to hide and activate or show a specific userform (always the same
userform). I'm looking to write a sub-routine that would automatically close
the current form and open the other one... no matter which form it is being
launched from.

Can someone please help?
 
P

PRegis08

I have 10 userforms... each will have a button/sub-routine that will point to
an 11th userform. I know generally I would just use this code to open/close
the necessary userforms but is there a way to replace the current userform
name with something general? Please see my example below:

userform1.hide
userform11.show

What I guess I am looking to do is create a sub-routine that closes which
ever of the 10 userforms that are active and call up the 11th

sub form11 ()

(blank).hide
userform11.show

end sub

Something like that? I don't know if that's possible.
 
S

Shyam Pillai

Why don't you pass the form as an argument to the sub routine?

sub form11 (MyForm as Form)

MyForm.hide
userform11.show

end sub

Call it from any form as follow:

Call form11(Me)


Regards,
Shyam Pillai

http://skp.mvps.org
 
P

PRegis08

Thank you so much for your help. Each of you. Shyam, I think this is
definitely going to solve my problem. I am getting a compiler error though?
User-defined type not defined. I must of forgotten something, somewhere?
 
S

Shyam Pillai

Change sub form11 (MyForm as Form)
to
sub form11 (MyForm as Object)

That should do it.


Regards,
Shyam Pillai
 

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