problem hide workbook and show userform

leap out

Board Regular
Joined
Dec 4, 2020
Messages
142
Office Version
  1. 2016
  2. 2010
hello

I no know what I'm asking it's possible I search in the internet efficient way to hide workbook and show userform only what I work in my file without effect the rests of files if there are open or open a new file
so what I note for many codes don't treat this problem what I want when I run the file then hide it and show userform and if I run again doesn't open the file at all and if I have another workbook is open , I don't have to open again to show it

short words when open my file hide workbook and show userform without any effects for the rests file whether i open a new workbook or workbook have already opened
if any body has any idea please provide me
thanks
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

severynm

Board Regular
Joined
Jan 8, 2021
Messages
199
Office Version
  1. 365
Platform
  1. Windows
See this answer to the same question, which just minimizes the current workbook.

If you want to interact with other worksheets in the background, the userform needs to be in Modeless mode. UserForm1.Show becomes UserForm1.Show vbModeless.

VBA Code:
Sub mrexcel1160509()
    ActiveWindow.WindowState = xlMinimized
    UserForm1.Show vbModeless
End Sub
 

leap out

Board Regular
Joined
Dec 4, 2020
Messages
142
Office Version
  1. 2016
  2. 2010
thanks ,but there are still problem about your code if i open another workbook it shows a workbook contain userform what I work for it , it supposes showing only the userform even i try opening the file again or open another workbook it must show the only userform without effect for it
 

severynm

Board Regular
Joined
Jan 8, 2021
Messages
199
Office Version
  1. 365
Platform
  1. Windows
So you want to show the userform as soon as the workbook opens? Add that code inside the Workbook_Open() function inside of the ThisWorkbook module. Anything in Workbook_Open() will automatically run as soon as the workbook is opened.
 

leap out

Board Regular
Joined
Dec 4, 2020
Messages
142
Office Version
  1. 2016
  2. 2010

ADVERTISEMENT

I know about it but the problem when I close the userform it shows the workbook
 

severynm

Board Regular
Joined
Jan 8, 2021
Messages
199
Office Version
  1. 365
Platform
  1. Windows
If you use purely the code above, the workbook stays minimized after the userform is closed. There must be something else you are doing to show the workbook again.

Unless we have a massive misunderstanding about what you are looking for. Screenshots or the workbook itself might help??
 

leap out

Board Regular
Joined
Dec 4, 2020
Messages
142
Office Version
  1. 2016
  2. 2010

ADVERTISEMENT

actually I don't want minimize the workbook what I would hide userform the working only on userform and when I close the userform should close whole file without remain the workbook file is open and if the userform open and if I open another workbook shouldn't open workbook which is relating the userform I work of it
 

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
8,253
Office Version
  1. 2016
Platform
  1. Windows
How about something like this :

In the UserForm Module:
VBA Code:
Option Explicit

Private Sub UserForm_Initialize()
    ThisWorkBook.Windows(1).Visible = False
End Sub

Private Sub UserForm_Terminate()
    If Application.Workbooks.Count = 1 Then
        ThisWorkBook.Save
        Application.Quit
    Else
        ThisWorkBook.Close True
    End If
End Sub

Is your userform Modal or Modeless ?
 

leap out

Board Regular
Joined
Dec 4, 2020
Messages
142
Office Version
  1. 2016
  2. 2010
@Jaafar Tribak well done ! my userform in model and if I have open file and I open the file contains userform then show the file is open I would show userform with minimize any file is open it doesn't supposes showing any file is open stay minimizing
 

Forum statistics

Threads
1,137,125
Messages
5,679,755
Members
419,855
Latest member
Eddier32

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