Results 1 to 7 of 7

Thread: Display macro enable/disable alert in an emailed file.

  1. #1
    Member
    Join Date
    Aug 2011
    Posts
    92
    Rep Power
    14

    Display macro enable/disable alert in an emailed file.

    Hi,

    I have the below macro code to display a message if macros are enable/disable. In the attached file there are 2 sheets 'Summary' and 'Info'. Info sheet is visible when macros are disabled and meanwhile summary is hidden. Summary file is only visible when macros are enabled. I am facing issue when I am emailing this file, the summary sheet doesn't hide even if the macros are disable. On strange thing I also noticed is that If I email this file while macros are enable in my excel, it doesn't work. But if I send this with macro disabled in my excel it works fine. Seeking experts help here.

    HTML Code:
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Sheets("info").Visible = True
    Sheets("summary").Visible = xlVeryHiddenEnd
    End Sub
    HTML Code:
    Private Sub Workbook_Open()
    Sheets("Summary").Visible = True
    Sheets("info").Visible = xlVeryHidden
    
    End Sub
    Test WB.xlsm

    Thanks

  2. #2
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi

    Put the code in BeforeSave event rather than BeforeClose event.
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  3. #3
    Member
    Join Date
    Aug 2011
    Posts
    92
    Rep Power
    14
    Hi Admin, thanks for your prompt reply. I tried the BeforeSave event, still not working.

    HTML Code:
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Sheets("info").Visible = True
    Sheets("summary").Visible = xlVeryHiddenEnd
    End Sub
    Thanks

  4. #4
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    OK

    Try this.

    Code:
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
        Sheets("info").Visible = True
        Sheets("summary").Visible = xlVeryHiddenEnd
        ThisWorkbook.Save
    End Sub
    Please note that this code will forcefully save the workbook each time when it closes.
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  5. #5
    Member
    Join Date
    Aug 2011
    Posts
    92
    Rep Power
    14
    Thanks admin, it worked. Appreciate your usual support.

    Thanks
    Raj

  6. #6
    Member p45cal's Avatar
    Join Date
    Oct 2013
    Posts
    94
    Rep Power
    12
    Shouldn't:
    xlVeryHiddenEnd
    be:
    xlVeryHidden
    ?

  7. #7
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Quote Originally Posted by p45cal View Post
    Shouldn't:
    xlVeryHiddenEnd
    be:
    xlVeryHidden
    ?
    I just copied the OP's code, haven't noticed that
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

Similar Threads

  1. Macro to fetch csv file and edit the file
    By dhivya.enjoy in forum Excel Help
    Replies: 6
    Last Post: 10-23-2013, 01:00 PM
  2. Replies: 3
    Last Post: 10-11-2013, 12:25 PM
  3. Replies: 2
    Last Post: 08-22-2013, 12:23 AM
  4. VBA To Display Pop Up Alert When Duplicate Entry Is Made
    By peter renton in forum Excel Help
    Replies: 20
    Last Post: 07-26-2013, 07:56 PM
  5. Disable OUTLOOK spellcheck using VBA
    By Varun.Dandona in forum Outlook Help
    Replies: 5
    Last Post: 10-25-2011, 10:06 PM

Posting Permissions

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