BUMP!! Please help!!!
VB code in Excel that is supposed to minimize Excel and allow user form to stand alone only works sometimes!! WITH PICTURES!!
I have a program written in Excel using vb. The first button basically starts the program as shown below. I am very new at this so please explain you responses!
I wrote this bit of code:
Sub ShowForm()
Application.WindowState = xlMinimized
Typeofcontainer.Show
End Sub
It basically tells Excel to minimize and allow the user form to run while it is minimized like so.
The problem is... it only works sometimes. It seems that if the program is shut down for any reason (or saved), then Excel comes up behind the user form like this?
Where is my problem? I can provide more info if necessary. This is driving me nuts!!! I also have this code written in the workbook start up to shut off auto calc., calc. at save and to save the workbook on close:
Private Sub Workbook_Open()
Application.Calculation = xlCalculateManual
Application.CalculateBeforeSave = False
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Save
End Sub
Could this cause the problem? Any ideas are appreciated!! Please help!
Brandon
Microsoft 365 and Office | Excel | For home | Windows
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
3 answers
Sort by: Most helpful
-
Anonymous
2014-03-05T15:28:26+00:00 -
Anonymous
2014-03-05T21:44:46+00:00 Try using
Application.Visible = False
Typeofcontainer.Show
and when the form closes,
Application.Visible = True
Does that work any better?
-
Anonymous
2014-03-06T20:44:43+00:00 Try using
Application.Visible = False
Typeofcontainer.Show
and when the form closes,
Application.Visible = True
Does that work any better?
This form is only the first, in a series of forms, that user input calls up. So, It moves from form, to form, to form and so on. In addition, the program is cyclic, meaning that when one user finishes their session and presses an "OK" button, the program returns to the beginning by bringing up the user form you see here. There are several operators that must access the Excel database to make corrections. To do this, they press the "QUIT" button and enter a password. The program shuts down, but the Excel icon is still present in the taskbar. Then the operator can access the workbook from the taskbar, make the corrections and then re-launch the program from the "Click Here to Begin" button shown in my original post. I originally tried this code and it caused quite a few issues, including attempts to open multiple instances of Excel and accidental closure of the Excel program... to name a few. In addition, I would have to add the .visible code to at least 20 "QUIT" buttons...1 on each user form in order to allow the operators to access the database from the taskbar. I really appreciate the response, but I don't think it will work in my case. Any other ideas? Can you think of why xlminimize doesn't work...part of the time?