Forum Discussion

Tullyk's avatar
Tullyk
Copper Contributor
Feb 24, 2019

how to create pop up message very time workbook is opened

Hi, i am wanting to create a pop up message every time my work book is opened, to tell every one to read the "instructions" sheet before editing. 

is there a way to do this?

thanks kelly

  • Damien_Rosario's avatar
    Damien_Rosario
    Silver Contributor

    Hi Tullyk 

     

    You could addin a simple message box that appears when you open the workbook.

     

    1. Add the Developer tab to your tab menu (right click onto a tab > Customize the Ribbon and tick Developer).

     

    2. Go to Developer tab and click onto Visual Basic.

     

    3. In the left side list under VBAProject (Book1), double click ThisWorkbook.

     

    4. Drop down the list box where it says (General) and choose Workbook.

     

    5. Type in msgbox("your message").

     

     

    6. Save As a Excel Macro-Enbaled Workbook (*.xlsm)

     

    When you open the file, you will see a yellow warning pop up the top to enable macro content. Clicking Enable will then all the code to run.

     

    7. If you want the message to appear without this prompt, you could turn it off in File > Options > Trust Center > Macro Settings > Enable all macros...

     

    Just note there are some security risks doing this as malicious code could be executed if you happen to open a dodgy file.

     

    Anyway hope that helps?

     

    Cheers

    Damien

    • FlyersKat1113's avatar
      FlyersKat1113
      Copper Contributor

      Damien_Rosario thank you so much for this! Is there a way to create a two line message? For example to say:

       

      EXCEPTIONS TEAM - please right-click and paste content as values.

       

      ALL TEAMS: please do NOT alter Conditional Formatting options of this sheet.

       

      When I tried hitting “enter” in VBA, it threw an error code.

       

      TIA!!

      • HansVogelaar's avatar
        HansVogelaar
        MVP

        FlyersKat1113 

        Like this:

        Private Sub Workbook_Open()
            MsgBox "EXCEPTIONS TEAM: please right-click and paste content as values" & vbCrLf & _
                "ALL TEAMS: please do NOT alter Conditional Formatting options of this sheet."
        End Sub

Resources