Excel vba-when i opened a new excel using useform it closes along with the userform

happycode

New Member
Joined
Aug 25, 2020
Messages
5
Office Version
  1. 2010
Platform
  1. Windows
Hi,
I have created a userform in a workbook named some 'x'. I made the userform to run automatically when this 'x' workbook opens by giving application.visible= false and userform.show.
I am validating some data in this user form using command buttons. Finally i want to open a validated workbook which will be created in the same location of the 'x' workbook. I kept a command button as open validated file and opened the validated file. But i dont want to close it. I just want to remain it opened and close only the user form and the 'x' workbook.
Even after closing the 'x' workbook i want the validated file to be opened only.
Please advise. Your comments are really appreciated.
 

Some videos you may like

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Anthony47

Well-known Member
Joined
Mar 29, 2006
Messages
1,941
Try opening the userform "modelessly":
VBA Code:
UserFormXYZ.Show vbModeless
Bye
 

happycode

New Member
Joined
Aug 25, 2020
Messages
5
Office Version
  1. 2010
Platform
  1. Windows
Try opening the userform "modelessly":
VBA Code:
UserFormXYZ.Show vbModeless
Bye
Even if i use modelessly, the opened validated file closes when the userform workbook is closed. I just want to have the final output workbook to be opened and do not close it.could you please help on this.
Thanks for posting!
 

Anthony47

Well-known Member
Joined
Mar 29, 2006
Messages
1,941
My guess is that the problem depends on how you close the userform and the "X" workbook. Please describe which is your process about that, as well as list the code that manages the userform events (especially UserForm_Deactivate and UserForm_Terminate) and any code you use to close workbook X

Bye
 

happycode

New Member
Joined
Aug 25, 2020
Messages
5
Office Version
  1. 2010
Platform
  1. Windows
My guess is that the problem depends on how you close the userform and the "X" workbook. Please describe which is your process about that, as well as list the code that manages the userform events (especially UserForm_Deactivate and UserForm_Terminate) and any code you use to close workbook X

Bye
I did not used terminate or deactivate events. I just used another command button to close the userform and workbook 'x'.
And i used queryclose to make the workbook opened for future code edit purpose.
Is there any other way to open a outpur result and leave it. And close only the userform and workbook 'x'.?
 

Anthony47

Well-known Member
Joined
Mar 29, 2006
Messages
1,941
Ok, so you close the other workbook with another button; whould you please show the code that you use for that operation? My guess is that somewhere you "quit" the excel application, but if you don't show what you use I shall stay with my guess and you stay with your problem ;)
 

Watch MrExcel Video

Forum statistics

Threads
1,114,528
Messages
5,548,574
Members
410,852
Latest member
WernerS
Top