Getting a .xlsm file to not execute code when being opened with VBA

前端 未结 2 707
醉话见心
醉话见心 2020-12-21 11:08

Have a macro in Excel. Part of that macro opens up other workbooks using Workbooks.Open(Filepath)

Some of the workbooks I\'m opening have (badly done) V

2条回答
  •  时光说笑
    2020-12-21 11:58

    You can disable the macros for newly opened files, open the workbook, and then re-enable the macros:

    Private Sub OpenWorkBookMacroDisabled(wbPath As String)
        Application.AutomationSecurity = msoAutomationSecurityForceDisable
        Workbooks.Open (wbPath)
        Application.AutomationSecurity = msoAutomationSecurityByUI
    End Sub
    

提交回复
热议问题