[Solved] VBA: On Opening - Security

  • Afternoon All,


    When opening a file you are asked to enable or disable macros - if you disable, you still get access to the file - is there a simple way to ensure the user always enables the macros?


    Cheers,


    Graham

    But I always say luck is where preparation meets opportunity (Justin Langer 23/11/01)

  • Hi there
    Try this: and I hope you are looking for this.


    Under Tools Menu >Macros>Security
    select security Level "LOW" (Beware of Virus) and Under Trusted Source, Select Trust access to Visual Basic Project.


    Regards


    Maqbool

  • Thanks Maqbool,


    Does your solution mean the excel program settings need to change, or is it part of the file?


    KR,


    Graham

    But I always say luck is where preparation meets opportunity (Justin Langer 23/11/01)

  • Whilst the answer already given will work it has obvious dangers. Also, you cannot generally control other users choices. Instead have a look at Dave's EnableMacros.zip here


    http://www.ozgrid.com/download/default.htm

  • Thanks Roy,


    I have downloaded them but my Winzip program cannot open it. I down loaded another and it would not open either.


    Is there something else I should be doing?


    KR GB

    But I always say luck is where preparation meets opportunity (Justin Langer 23/11/01)

  • Roy,


    No need to respond, typically I picked probably the only way to download them without actually downloading them, if you know what I mean.


    I tried again using DAP and no problem - question answered.


    Thanks heaps,


    Graham


    ps Who you going for in the World Cup - starts 10days!

    But I always say luck is where preparation meets opportunity (Justin Langer 23/11/01)

  • Gidday Guys,


    The code from web site is excellent, however, for my small brain I need an explaination of some bits and pieces.


    the code


    Public bIsClosing As Boolean
    Dim wsSheet As Worksheet


    Sub HideAll()


    Application.ScreenUpdating = False
    For Each wsSheet In ThisWorkbook.Worksheets
    If wsSheet.CodeName = "Sheet1" Then
    wsSheet.Visible = xlSheetVisible
    Else
    wsSheet.Visible = xlSheetVeryHidden
    End If
    Next wsSheet
    Application.ScreenUpdating = True


    End Sub


    Sub ShowAll()
    bIsClosing = False


    For Each wsSheet In ThisWorkbook.Worksheets
    If wsSheet.CodeName <> "Sheet1" Then
    wsSheet.Visible = xlSheetVisible
    End If
    Next wsSheet


    Sheet1.Visible = xlSheetVeryHidden
    End Sub



    What is "bIsClosing" - I cannot find any reference to it in any of the references I have. And is it necessary???


    Cheers,


    GB

    But I always say luck is where preparation meets opportunity (Justin Langer 23/11/01)

  • Yes, it is necessary, Its just a variable that Dave declared. "BisClosing" (book is closing true/false). He could just as easily called it "Hey_Man_I_am_Closing".

  • Thanks Doug,


    I think I understand - the code (from module) from my last post needs to combine with that Dave put into "Thisworkbook" - by doing this; no matter how the file is opened or closed, it requires the user to enable macros or nothing other than the "Sheet1!" is visible. - Correct?


    Graham

    But I always say luck is where preparation meets opportunity (Justin Langer 23/11/01)

  • Hi Doug


    You are correct, the main sheets are hidden at all times, but with macros enable the open all sheets macro runs and the "splash" sheet is hidden when the workbook opens

  • Many thanks fellas,


    Modified the code to suit my file, leant more about worksheet indexs and naming - works beautifully now.


    I just love it when things work as you expect them to.....


    GB

    But I always say luck is where preparation meets opportunity (Justin Langer 23/11/01)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!