Error adding a new sheet to a XLSM Macro Enabled Excel File

前端 未结 2 1520
傲寒
傲寒 2021-01-29 11:29

I want to add a new sheet in a Macro Enabled Excel File using VBA.

It doesn\'t matter the method that I use:

  • Sheets.add
  • Copying and pasting a she
2条回答
  •  攒了一身酷
    2021-01-29 12:33

    I was experiencing the same issue, on a Windows 7 computer with Excel version 16.0.10730.20264 32-bit, the code ran fine without issue. However, on a Windows 10 computer with the same Excel install version, the macro would immediately stop execution following the Sheets.Add or Worksheets.Add line. I found that this was only happening where I was attempting to add a sheet to a workbook that contained VBA code. The issue is caused by the macro security settings on the computer. If you set Automation Security to Low before opening the workbook, you should no longer get the error: Application.AutomationSecurity = msoAutomationSecurityLow

提交回复
热议问题