+ Reply to Thread
Results 1 to 5 of 5

Thread: Open excel with only a userform

  1. #1
    Registered User
    Join Date
    01-20-2012
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    18

    Open excel with only a userform

    Hi everyone
    I am working on a "secure" excel workbook. Is it possible to have excel open an userform BEFORE opening any worksheet?
    I started creating an userform wich let the user select the sheet on wich he want to work and opens that worksheet.
    I am having a hard time finding the way to hide/unhide sheets with vba I thought it would be something like: "sheet4.visible=false" ... anyone know how I could do it?
    Also, my workbook is really heavy and I don't want to have extra sheets, is there another way to hide content from user than creating a blank sheet on top of wich my userform would appear?
    Thanks for your help, I hope you understood my problems and have a solution!

    Bénédict Soucy

    p.s. I'm sorry for my english, I did my best but I'm french. I didn't go on french forum because I really want an answer!
    Last edited by benedictexcel; 01-20-2012 at 04:18 PM.

  2. #2
    Forum Contributor
    Join Date
    06-16-2011
    Location
    London
    MS-Off Ver
    Excel XP
    Posts
    189

    Re: Open excel with only a userform

    You need a loading screen, ie a worksheet that you dont mind users seeing before your code opens a userform. You'll also need to ensure that your "loading" worksheet is always the first sheet seen when opening your spreadsheet.

    In: Microsoft Excel Objects
    ThisWorkbook

    Put this code:

    
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    
    ' prevents users saving copies
    If SaveAsUI Then
    Cancel = True
    End
    End If
    
    ' ensures workbook is always saved with the "Loading" worksheet visible first.
    
    ActiveWorkbook.Unprotect Password:="whatever"
    Sheets("loading").Visible = True
    Sheets("loading").Select
    ActiveWorkbook.Protect Password:="whatever", Structure:=True, Windows:=False
    
    end sub

  3. #3
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel 2007
    Posts
    825

    Re: Open excel with only a userform

    hi,
    no, you can not, you must have at least one visible sheet.
    choose one sheet in order to be visible, set StandardWidth to 0, so yr Sheet will become blue.
    just for test see the the file attached!

    Private Sub Workbook_Open()
    Dim sh As Worksheet
      For Each sh In Worksheets
        If sh.Name <> "Start" Then sh.Visible = xlSheetVeryHidden   ' "Start" is your visible sheet
      Next
    UserForm1.Show
    End Sub
    and show the sheets
    Private Sub CommandButton1_Click()
    Dim sh As Worksheet   'this is a commandbutton in a userform
      For Each sh In Worksheets
        If sh.Name <> "Start" Then sh.Visible = xlSheetVisible
      Next
    End Sub
    Attached Files Attached Files
    Regards, John

  4. #4
    Registered User
    Join Date
    01-20-2012
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Open excel with only a userform

    Thanks it helped!

  5. #5
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel 2007
    Posts
    825

    Re: Open excel with only a userform

    glad I could help you!
    Regards, John

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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