PDA

View Full Version : Can only run a User Form once..?



ReltubP
12-02-2020, 05:48 AM
I picked up a document from a colleague the other day. After running one of the user forms in the document the macro button is then greyed out, and the user form can only be accessed and run through the VBA editor.

Anyone know why I'm getting this behaviour?

Logit
12-02-2020, 09:41 AM
.
Something written in the macro code ?

ReltubP
12-02-2020, 04:09 PM
Not that I can see.

Is this a common issue?

Logit
12-02-2020, 06:19 PM
.
No, it is not common.

Post your code / workbook.

ReltubP
12-02-2020, 06:31 PM
In fact, upon thought, the ‘Interactive Userform examples’ word doc from Greg Maxey’s site does the same thing – only when you populate the first user form. Well it does for me anyways.

https://gregmaxey.com/word_tip_pages/interactive_userforms.html


As you can probably tell, I’m still new to this.

Logit
12-02-2020, 06:58 PM
.
Using the macro code from the linked resource you provided in your last post,
BOTH UserForm commandbuttons include this line in the macro :


Me.Hide

When you click the button on either form, it hides the userform. Making it appear
as though the form can only be used once.

ReltubP
12-02-2020, 08:25 PM
Commenting out the Me.Hide did not change this behaviour.

Logit
12-03-2020, 08:55 AM
.
I don't have an answer. My experience lies with VBA in Excel not Word.

As an experiment, I created a third UserForm using the same CommandButton code as the other two userforms. This new form
disappeared as well after clicking the button.

I reviewed all of the code in all Userforms and Modules in the example download file provided in the resource link you posted.
I cannot find any other references to closing or hiding the userform in the code.

I am at a loss to explain.

Logit
12-03-2020, 09:51 AM
.
I created a new Word document with a User Form. This example ... the Form remains visible.

Either the example you provided is corrupted or there is an unknown attribute causing the UserForm to auto-close.

ReltubP
12-03-2020, 08:38 PM
Thanks for your time...

Logit
12-03-2020, 09:23 PM
.
I am sorry I couldn't have been more helpful. I wish you well in your search for an answer.

Best wishes !

Paul_Hossler
12-07-2020, 09:53 AM
Anyone know why I'm getting this behaviour?

Not without seeing the document

Clean any sensitive information, and post it

Chas Kenyon
12-07-2020, 08:21 PM
How are you starting or calling your form?
Do you have a MyUserForm.Show command?

Your actual code and document/template would help.