How to make the workbook of Userform Invisible when opening /closing other workbooks?

MHD

New Member
Joined
Mar 16, 2021
Messages
37
Office Version
  1. 2019
Hello everyone

I have a question that I hope to find a solution with you

I have created a user form and it works perfectly
I made the workbook become invisible upon opening the file,
The problem that I face when I open another workbook, Excel opens the form user workbook too !,
I want it to remain invisible to the user when opening or closing other Excel files.

Any help please

VBA Code:
Private Sub Workbook_Open()

Application.Visible = False
Sheets("Invoice_Labor").Visible = xlSheetVeryHidden
Sheets("Lists & File Name").Visible = xlSheetVeryHidden
UF_Invoice.Show (vbModeless)

End Sub
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

vw412

Active Member
Joined
Dec 16, 2011
Messages
343
Office Version
  1. 2019
  2. 2016
  3. 2010
  4. 2007
Platform
  1. Windows
Just looking at the code you supplied, "Application.Visible = False" applies to the current Excel session, not to the Workbook just opened. My guess is that when you open another workbook the Application.Visible property is reset and since it is for Excel and not for the Workbook, all workbooks will become visible.

The Sheets.Visible statements will make those two sheets invisible but are there any more sheets in that workbook?

I am assuming the userform is where you select another workbook to open. I would need more info on the rest of your coding and design details before being able to test some solutions to your problem.
 
  • Like
Reactions: MHD

MHD

New Member
Joined
Mar 16, 2021
Messages
37
Office Version
  1. 2019
Thanks for your help vw412

Yes, that's exactly what happens!

If there are other work files already open, the code hides them and only shows the user form.
And when opening another excel workbook during working on the UserForm, it will display all the work files in addition to the UserForm file (sheets "Home").

As for the worksheets, there are three main worksheets in addition to the "Home" worksheet that I have added to make my code works (I do not know if there is a possibility to remove it and hide all other sheets and show the UserForm only).

Is there a way to make the code shows the UserForm "UF_Invoice" only with the ability to open or close other workbooks?

Regards
 

vw412

Active Member
Joined
Dec 16, 2011
Messages
343
Office Version
  1. 2019
  2. 2016
  3. 2010
  4. 2007
Platform
  1. Windows
When user has selected a workbook to open from the Userform, will he need to have that workbook open to use it, but keep the original workbook hidden?
 
  • Like
Reactions: MHD

MHD

New Member
Joined
Mar 16, 2021
Messages
37
Office Version
  1. 2019
Hello vw412

Working on my UserForm does not need to open any other workbooks so I did not add that to my design.
Nevertheless; I do not want the user to face any problems when using my UserForm, so I want this code "
VBA Code:
Private Sub Workbook_Open()
Application.Windows("Invoice Maker V2.1").Visible = False
Sheets("Invoice").Visible = xlSheetVeryHidden
Sheets("Invoice_Labor").Visible = xlSheetVeryHidden
Sheets("Lists & File Name").Visible = xlSheetVeryHidden
UF_Invoice.Show (vbModeless)
End Sub
" to be more flexible, as the user can work on other workbooks (open, close, save ...etc) normally without any obstacles. of course, with this flexibility, I want to keep the UserForm workbook hidden, and only show the UserForm.

As you can see, I made some improvements to the previous code to make it more flexible, but the problem facing the user now is that when he tries to close another opened workbook, the Excel application asks to close the UserForm workbook too.

Thanks for following this thread
 

vw412

Active Member
Joined
Dec 16, 2011
Messages
343
Office Version
  1. 2019
  2. 2016
  3. 2010
  4. 2007
Platform
  1. Windows
Is it possible for you to upload your workbook to a file sharing site like Dropbox so we can examine it to understand what you are trying to do so we can better help you? I for one am struggling with understanding but do want to help.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,405
Messages
5,769,881
Members
425,578
Latest member
Ckrysa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top