+ Reply to Thread
Results 1 to 6 of 6

userform only not worksheet

  1. #1
    Registered User
    Join Date
    01-31-2006
    Posts
    20

    userform only not worksheet

    I created a userform called frmLeaveRequest that I want to start when the user double clicks on the excel file

    Please Login or Register  to view this content.
    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??

    Please Login or Register  to view this content.

  2. #2
    Tom Hutchins
    Guest

    RE: userform only not worksheet

    If I understand you correctly, what you are asking can't be done with Excel.
    An open workbook must have at least one visible sheet. If you close the
    workbook, your userform is unloaded also.

    You could make all the sheets exept one blank sheet xlVeryHidden. In the
    VBA, password protect the project. Have a Workbook_Open event turn off
    ScreenUpdating after displaying your userform. Of course, the event won't
    fire (and your userform won't be displayed) if the user disables macros - and
    ulimately, you can't prevent that.

    You could do what you describe using VB6 or VB.Net.

    Hope this helps,

    Hutch

    "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
    >
    >


  3. #3
    JNW
    Guest

    RE: userform only not worksheet

    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
    >
    >


  4. #4
    Tom Hutchins
    Guest

    RE: userform only not worksheet

    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
    > >
    > >


  5. #5
    JNW
    Guest

    RE: userform only not worksheet

    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
    > > >
    > > >


  6. #6
    Peter T
    Guest

    Re: userform only not worksheet

    Just to add, although the workbook must contain at least one visible sheet
    the workbook could be hidden (like Personal.xls). Or the workbook could be
    an addin, even if named *.xls albeit a bit unconventional.

    It's not clear if the OP wants to hide everything in Excel except his form,
    if so go with JNW's. But if need to keep existing workbook visible put code
    in a hidden workbook. Perhaps even a combination, if no other visible
    workbooks open make XL invisible, otherwise leave it as is.

    Regards,
    Peter T

    "Tom Hutchins" <[email protected]> wrote in message
    news:[email protected]...
    > If I understand you correctly, what you are asking can't be done with

    Excel.
    > An open workbook must have at least one visible sheet. If you close the
    > workbook, your userform is unloaded also.
    >
    > You could make all the sheets exept one blank sheet xlVeryHidden. In the
    > VBA, password protect the project. Have a Workbook_Open event turn off
    > ScreenUpdating after displaying your userform. Of course, the event won't
    > fire (and your userform won't be displayed) if the user disables macros -

    and
    > ulimately, you can't prevent that.
    >
    > You could do what you describe using VB6 or VB.Net.
    >
    > Hope this helps,
    >
    > Hutch
    >
    > "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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1