How to prevent access with macros disabled? [closed]

1

I have a registration form that appears as soon as we open the worksheet. The registration list (in the sheets) is invisible and can only be accessed by password when clicking the "Database" button. However, when a person accesses it for the first time on their machine, the Excel warning appears to enable the macros, and the contents of the worksheet (in the sheets) ends up being exposed to the user. I would like only one warning sheet to appear, in order to open the form only if it enables the macros before. I already created it with the guidelines and I left it in VeryHidden, but wanted to know what the code would be to put in ThisWorkbook. I think it would be in Workbook_BeforeClose.

Would anyone help?

    
asked by anonymous 05.03.2017 / 02:48

1 answer

0

I got it !!!!

My code looks like this:

Private Sub Workbook_BeforeClose(Cancel As Boolean)

  'Passo 1: Declarando variáveis

  'Dim ws As Worksheet

  'Passo 2: Deixa visível a Sheet inicial

  'Sheets("Alerta").Visible = xlSheetVisible

  'Passo 3: Inicia looping em todas as worksheets

  'For Each ws In ThisWorkbook.Worksheets

  'Passo 4: Checa o nome de cada Worksheet

  'If ws.Name <> "Alerta" Then

  'Passo 5: Esconde a Sheet

  'ws.Visible = xlVeryHidden

  End If

  'Passo 6: Loop na próxima Worksheet

  'Next ws

  'Passo 7: Salva a planilha

  'ThisWorkbook.Save

End Sub

Private Sub Workbook_Open()

  'Passo 1: Declarando variáveis

  'Dim ws As Worksheet

  'Passo 2: Inicia looping em todas as worksheets

  'For Each ws In ThisWorkbook.Worksheets

  'Passo 3: Mostra todas as Sheets

  'ws.Visible = xlSheetVisible

  'Passo 4: Loop na próxima Wworksheet

  'Next ws

  'Passo 5: Esconde todas as Sheets

  'Application.Visible = False

  'Passo 6: Mostra apenas o Formulário de Cadastro ao abrir a Workbook

  'FormulárioReserva.Show


End Sub

Thank you for your attention !!!!! :)

    
08.03.2017 / 05:42