PDA

View Full Version : Disable UserForm



Strongs
10-02-2007, 05:11 AM
Hi everyone,

I am copying information from many documents and pasting into a master document. The master document opens the many documents loops through the other documents selecting the required information (thanks to Tony for his input on this one). However, the many documents all have a UserForm that fires up when the document is opened. This causes the macro in the calling document (master document) to come to a grinding halt.

Is there any way to disable the userform in the many documents so that this doesn't happen?

Thanks for your help.

Oorang
10-02-2007, 07:35 AM
Excel or word?

Strongs
10-02-2007, 10:28 AM
Hi Aaron,

Word is the culprit. Word master document, copying from many Word documents.

Oorang
10-03-2007, 07:28 AM
http://word.mvps.org/FAQs/InterDev/DisableAutoMacros.htm

Strongs
10-03-2007, 12:21 PM
Hi Aaron,

Thanks for the info. I had tried that, but the form just kept on firing up. I tried placing the DisableMacro code both inside the loop for every instance of documents opened and also outside the loop as global catch all. Both methods failed to stop the UserForm from firing up.

I have also tried setting the User Form modal property to false to see if that would work, but again no luck.

Tried scouring the web, but no solutions here either.

Regards,

Paul

Oorang
10-03-2007, 09:42 PM
What is triggering the forms?

Strongs
10-03-2007, 10:57 PM
in the many documents "ThisDocument" UserForm.Show so it is being called when the document is opened via a FileDialog msoFileDialogOpen call.

I also tried a boolean in the many forms using the UserControl function, but because the many documents are being called by the FileDialog method, then the document assumes that it is the user opening the document.

The many document contains two userforms. These are necessary because two different users will be accessing the document and completing their part of the document through the userforms. When user 1 has completed their part, the second form is activated ready for user 2 to enter their info. Once user 2 has completed their part, then the code in the many documents checks to see if a critical field has been completed. if so, then the second form is also suppressed.

If need be, I can instruct the user not to complete the master document until user 2 has completed their part of the many document and then this problem ceases to be an issue. The master document is only copying information that user 1 completed.

However, human nature being as it is, this probably wouldn't be a viable option.

Many thanks for your help.

regards

fumei
10-04-2007, 06:43 AM
One more reason to not use Master/Subdocuments. These have been buggy and difficult since day one.

Why are they being called via FileDialog, rather than just opened directly?

Could you post some actual code?

I assume the userform .Show is in the Document_Open procedure. Could you add a boolean global variable to the Master? A NoUserform variable. Set as True by the Master, when a subdoc is opened, that subdoc (in Document_Open) checks for that variable, and if True, does not open the userform; but if false (or not existing - as the master is not open) does open the useform.

Strongs
10-07-2007, 05:14 AM
Hi Gerry,

The documents are being called via a FileDialog because the amount of files and where they are stored will vary from user to user.

Below is the code from the many documents stored in the Document_Open procedure:

Private Sub Document_Open()
Dim initMsg As Long
If ActiveDocument.ProtectionType = wdAllowOnlyFormFields Then
User2Fm.Show
Exit Sub
Else

initMsg = MsgBox("Blah Blah")
If initMsg = vbYes Then
User1Fm.Show
Else
ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End If
End If

End Sub

This is the code from the main procedure in the many documents that supresses the User2Fm if a critical field is completed:

If ActiveDocument.FormFields("Blah").Result <> "" Then
Unload Me
Exit Sub

I will give your suggestion of a Global variable a try as soon as possible.

Thanks for your help,

Regards