Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: auto close

  1. #1
    New Member
    Join Date
    Mar 2002
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Today is 28.MAR.2002
    A1 is 27.mar.2002

    if file is open today it should not work in anyway but just close.

  2. #2
    BatCoder
    Join Date
    Feb 2002
    Location
    Turkey
    Posts
    813
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    Double click on thisworkbook object in VBA project and open the code. Then find the Sub Workbook_Open and use the code below..
    'Assume you dont want to show sheet1
    Private Sub Workbook_Open()
    If Sheet1.Cells(1, 1) < Now() Then
    Close False
    Else
    'This part avoid using sheet1 if user opens the workbook by clicking Disable Macros. So you need to set Sheet1.Visible property in Propertie window to 2 (xlSheetVeryHidden)
    Sheet1.Visible = xlSheetVisible
    End If
    End Sub

    'To make sheet1 xlVeryHidden before closing workbook (after making some changes etc)
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Sheet1.Visible = xlSheetVeryHidden
    End Sub

    Or some other ways like protecting and unprotecting sheets in code with this way.

    regards
    Suat

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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