Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide or minimize workbook 2

Status
Not open for further replies.

bozic12

MIS
Jan 23, 2003
48
US
Is there anyway in VBA to have the workbook hide, or at least minimize. I have a user form show upon workbook_open, and the worksheets are only used for back end data storage. I would like for only the form to be showing, without the workbook visible behind it. Ideally, I would like to have a button on the form that, when clicked, asks for a password so that only certified people can view and change the worksheets. I know a way to do this, but I would like for the workbook to be hidden until the password is verified.
 
You can hide all but one of the worksheets. The remaining worksheet can be one that has no real information, just a copyright notice for example. Then unhide the sheets when the password is verified.
For example

for each Sh in thisworkbook.sheets
if Sh.name<>&quot;Start&quot; then Sh.visible=xlSheetVeryHidden
next Sh
..get password here..
if password correct then
for each Sh in thisworkbook.sheets
Sh.visible=true
next Sh
Rob
[flowerface]
 
Rob, I had thought of that. But, is there code that can trigger the minimize functionality of excel. I know that if I open VBA from the workbook, then minimize Excel, then run the user form through VBA, Excel remains minimized and the user form still works fine with the data from the worksheets. So if i can, via code, minimize the workbook, then user_form.show, that might work, I just don't know if code exists to minimize the workbook. And to Pcfred, I had tried that as well and it didn't work. I think that only may work for worksheets and objects within the workbook, not the entire application of Excel.
 
Yes, that might work as well:

ActiveWindow.WindowState = xlMinimized
PasswordForm.Show
ActiveWindow.WindowState = xlMaximized

Rob
[flowerface]
 
Rob,
that bit of code really helps. it will help a lot for future applications as well. Thank you, and thanks to everyone else for their suggestions!!

-Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top