简体   繁体   English

隐藏工作簿/工作表Excel VBA

[英]Hide workbook/worksheets Excel VBA

I have a simple Microsoft Excel spreadsheet with a few tabs. 我有一个带有几个选项卡的简单Microsoft Excel电子表格。 On opening the workbook I have a USER LOGIN form that loads up and asks for login and password. 打开工作簿时,我有一个“用户登录”表单,该表单可以加载并要求输入登录名和密码。 What I'm trying to do is somehow not let the user see the sheets in the workbook until they've successfully logged in. The problem I'm seeing is that one of my sheets has a macro in it, so what I do 我正在尝试做的是某种方式让用户在成功登录之前不让用户看到工作簿中的工作表。我看到的问题是我的工作表中有一个宏,所以我该怎么做

sheet1.visible=xlhidden

it gives me a debug error. 它给了我一个调试错误。 However, even if I skipped that sheet and hid all the other ones - and on proper login I tried to make them Visible=xlVisible, they still did not become visible. 但是,即使我跳过了该工作表并隐藏了所有其他工作表-并在正确登录后尝试将它们设置为Visible = xlVisible,它们仍然不可见。 How would I go about something like that? 我该怎么办?

Is there some kind of a way to be able to hide the workbook possibly and then make it visible after successful login? 有什么方法可以隐藏工作簿,然后在成功登录后使其可见?

xlhidden is not an acceptable value for Worksheet().Visible . xlhidden不是Worksheet().Visible的可接受值。

  • Sheet1.Visible = xlSheetVisible makes the Worksheet visible Sheet1.Visible = xlSheetVisible使工作表可见
  • Sheet1.Visible = xlSheetHidden : hides the Worksheet but allows users to unhide it Sheet1.Visible = xlSheetHidden :隐藏工作表,但允许用户取消隐藏它
  • Sheet1.Visible = xlSheetVeryHidden : hides the Worksheet and prevents users from unhiding it Sheet1.Visible = xlSheetVeryHidden :隐藏工作表并防止用户Sheet1.Visible = xlSheetVeryHidden隐藏它

    在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM