Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Very cool. I stand corrected - I forgot about Application.Visible, because I
never use it. Just wanted to mention that the userform needs its ShowModal property set to False for this to work. Regards, Hutch "JNW" wrote: The following should work. Excel is hidden when the workbook is opened just leaving the form visible. When the workbook is closed it makes Excel visible and checks to see how many workbooks are open. If more than one workbook is open it only closes ThisWorkbook. If only one workbook then close excel. Private Sub Workbook_Open() frmLeaveRequest.Show Application.Visible = False End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.Visible = True If Workbooks.Count 1 Then ThisWorkbook.Close False 'Change to true if you want it to save the file. Else Application.Quit End if End Sub -- JNW "cedtech23" wrote: I created a userform called frmLeaveRequest that I want to start when the user double clicks on the excel file Code: -------------------- Private Sub Workbook_Open() frmLeaveRequest.Show End Sub -------------------- I don't want the worksheet to be visible to the user, just the userform How can I do this? I also want to close the active workbook and Excel if there are no other active workbook. What else do I have to and to this code to accomplish this?? Code: -------------------- Private Sub cmdExit_Click() ActiveWorkbook.Close End Sub -------------------- -- cedtech23 ------------------------------------------------------------------------ cedtech23's Profile: http://www.excelforum.com/member.php...o&userid=31022 View this thread: http://www.excelforum.com/showthread...hreadid=563330 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Tom. Forgot that bit.
-- JNW "Tom Hutchins" wrote: Very cool. I stand corrected - I forgot about Application.Visible, because I never use it. Just wanted to mention that the userform needs its ShowModal property set to False for this to work. Regards, Hutch "JNW" wrote: The following should work. Excel is hidden when the workbook is opened just leaving the form visible. When the workbook is closed it makes Excel visible and checks to see how many workbooks are open. If more than one workbook is open it only closes ThisWorkbook. If only one workbook then close excel. Private Sub Workbook_Open() frmLeaveRequest.Show Application.Visible = False End Sub Private Sub Workbook_BeforeClose(Cancel As Boolean) Application.Visible = True If Workbooks.Count 1 Then ThisWorkbook.Close False 'Change to true if you want it to save the file. Else Application.Quit End if End Sub -- JNW "cedtech23" wrote: I created a userform called frmLeaveRequest that I want to start when the user double clicks on the excel file Code: -------------------- Private Sub Workbook_Open() frmLeaveRequest.Show End Sub -------------------- I don't want the worksheet to be visible to the user, just the userform How can I do this? I also want to close the active workbook and Excel if there are no other active workbook. What else do I have to and to this code to accomplish this?? Code: -------------------- Private Sub cmdExit_Click() ActiveWorkbook.Close End Sub -------------------- -- cedtech23 ------------------------------------------------------------------------ cedtech23's Profile: http://www.excelforum.com/member.php...o&userid=31022 View this thread: http://www.excelforum.com/showthread...hreadid=563330 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Viewing a worksheet within a Userform | Excel Programming | |||
UserForm for each Worksheet | Excel Programming | |||
How do I Open A UserForm in a Worksheet | Excel Programming | |||
Data from userform to worksheet | Excel Programming | |||
How can I use a worksheet while running a userform? | Excel Programming |