Yahoo Answers akan ditutup pada 4 Mei 2021 dan situs web Yahoo Answers sekarang tersedia dalam mode baca saja. Tidak akan ada perubahan pada properti atau layanan Yahoo lainnya, atau akun Yahoo Anda. Anda dapat memperoleh informasi lebih lanjut tentang penutupan Yahoo Answers dan cara mengunduh data Anda di halaman bantuan ini.

Ana Dewi ditanyakan dalam Computers & InternetProgramming & Design · 7 tahun yang lalu

Force user to enable macro?

Ask again dear friend.

I have a workbook consist of sheet1, sheet2, sheet3, sheet4, sheet5, sheet6, sheet7 named "HOME". I want to write VBA codes to force user to enable macro settings. When macro still disabled, I want sheet "HOME" will be displayed, other sheets is hidden. When macro is enabled all sheets including sheet "HOME" displayed.

Thanks in advanced for your help.

1 Jawaban

Relevansi
  • 7 tahun yang lalu
    Jawaban Favorit

    Copy both event handlers below to the clipboard (highlight the entire code, right click inside the highlighted area, and 'Copy'):

    Private Sub Workbook_BeforeClose(Cancel As Boolean)

    For Each ws In Sheets

    If UCase(ws.Name) <> "HOME" Then

    ws.Visible = xlSheetVeryHidden

    End If

    Next

    End Sub

    Private Sub Workbook_Open()

    For Each ws In Sheets

    ws.Visible = True

    Next

    End Sub

    Press ALT + F11 (Function Key F11)

    Double click 'This Workbook' in the Microsoft Excel VBA Project Objects in the upper left quadrant.

    Paste the event handlers into the workbook module editing area to the right.

    Close the VBE and save the workbook.

    Note: this process will make the sheets 'Very Hidden' when the workbook is closed. That means that they will not appear in the Format >Sheet > Unhide table.

Masih ada pertanyaan? Dapatkan jawaban Anda dengan bertanya sekarang.