Excel VBA:启用宏设置 [英] Excel VBA: Enabling Macro Settings

查看:806
本文介绍了Excel VBA:启用宏设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在打开工作表时,我写了一个宏方法来自动调整Excel工作表中的列。但是,如果用户在Excel中没有启用宏,则此解决方案不起作用。

I wrote a macro method to auto-size the columns in an Excel sheet upon opening the sheet. However, this solution does not work in the case that the user has not enabled macros in Excel.

有没有办法检查用户是否在Excel中禁用VBA宏,然后使用Excel VBA代码启用宏?

Is there any way to check if the user has VBA macros disabled in Excel, and then enable the macros with Excel VBA code?

推荐答案

这样做的标准方法是强制用户启用宏通过使用启动屏幕。

The standard way of doing this is to force the user to enable macros by use of a splash screen.


  • 工作簿中除了一个垃圾屏幕之外的所有工作表都是
    隐藏(只能通过VBA或VBA编辑器更改)

  • 如果启用宏:

    1)当工作簿打开时,代码取消隐藏所有这些非常隐藏的表格

    2)当工作簿关闭时,所有这些工作表都被非常隐藏

  • 如果未启用宏,则用户只能看到请启用宏,关闭并重新打开此文件的Splash屏幕。

  • All the sheets in the workbook except for a spash screen are made very hidden (which can only be changed via VBA or the VBA editor)
  • if macros are enabled:
    1) When the workbook opens, the code unhides all these very hidden sheets
    2) When the workbook closes then all these sheets are made very hidden again
  • If macros are not enabled then the user can only see the Splash Screen saying "Please enable macros, close and then re-open this file"

这个技术的完整代码的两个链接que列在下面

Two links with full code for this technique are listed below


  1. Brad Yundt涵盖了这个这里在TekTips

  2. Jonske 在VBAeXpress

  1. Brad Yundt covers this here at TekTips
  2. Jonske at VBAeXpress

这篇关于Excel VBA:启用宏设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆