XL5: Macro Cannot Set Module to xlVeryHidden
ID: Q131551
|
The information in this article applies to:
-
Microsoft Excel for Windows, versions 5.0, 5.0c
-
Microsoft Excel for the Macintosh, versions 5.0, 5.0a
-
Microsoft Excel for Windows NT, version 5.0
SYMPTOMS
When you set the Visible property of a module to xlVeryHidden, you may
receive the following error message:
Macro Error 1005:
Unable to set the Visible Property of the Module Class
CAUSE
This error will occur if the module that is being hidden contains a macro
that is currently running.
WORKAROUND
If you would like to set the modules in a workbook to VeryHidden after you
have finished creating them, follow these steps:
- Insert a new module sheet by choosing Insert, Macro, Module from the
menus.
- Type the following example macro on the new module sheet:
Sub HideModules()
For each m in Modules
If m.Name <> Activesheet.Name Then m.Visible = xlVeryHidden
Next
End Sub
- While the new module is still the active sheet, run the HideModules
macro by choosing Macro from the Tools menu. In the Macro Dialog Box,
select the HideModules macro and choose Run.
- After running the macro, all other modules will be hidden. Delete the
new module by choosing Edit, Delete Sheet.
Microsoft provides programming examples for illustration only, without
warranty either expressed or implied, including, but not limited to, the
implied warranties of merchantability and/or fitness for a particular
purpose. This article assumes that you are familiar with the programming
language being demonstrated and the tools used to create and debug
procedures. Microsoft support professionals can help explain the functionality
of a particular procedure, but they will not modify these examples to
provide added functionality or construct procedures to meet your specific
needs. If you have limited programming experience, you may want to contact
the Microsoft fee-based consulting line at (800) 936-5200. For more
information about the support options available from Microsoft, please see
the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/overview/overview.asp
STATUS
This behavior is by design of the versions of Microsoft Excel listed at the
beginning of this article.
MORE INFORMATION
In Microsoft Excel, setting the Visible Property of an object to
xlVeryHidden hides the object so that it may only be unhidden by setting
the Visible Property to True. For module sheets, this feature is primarily
used to add a measure of protection to the macros in a workbook.
NOTE: You will also receive this error message in two other situations:
- If the module you are trying to hide with the xlveryhidden property
contains a variable declared as Public.
- The module with the code to hide another module also calls a macro from
the module it is trying to hide.
For more information about the xlVeryHidden property, please see the
following articles in the Microsoft Knowledge Base:
Q128192 Can't Insert Sheet Based on Template with Hidden Sheet
Q128373 Macro Cannot Determine If Sheet Is VeryHidden
Q127944 Sheet Based on Template with Hidden Sheet Not Inserted
REFERENCES
For more information about the Visible property, choose the Search button
in Programming with Visual Basic Help and type:
visible property
Additional query words:
very hidden XL5
Keywords : kbprg
Version : MACINTOSH:5.0,5.0a; WINDOWS:5.0,5.0c; winnt:5.0
Platform : MACINTOSH WINDOWS winnt
Issue type :