Use Python to Inject Macros into Spreadsheets

前端 未结 4 764
自闭症患者
自闭症患者 2020-11-30 04:02

I\'ve got a macro that I\'d like a bunch of existing spreadsheets to use. The only problem is that there are so many spreadsheets that it would be too time consuming to do i

4条回答
  •  抹茶落季
    2020-11-30 04:42

    What @Dirk and @dilbert mentioned works great. You can also add this piece of code which will programmatically enable access to the `VBA object module'

    import win32api
    import win32con
    
    key = win32api.RegOpenKeyEx(win32con.HKEY_CURRENT_USER,
                                "Software\\Microsoft\\Office\\16.0\\Excel"
                                + "\\Security", 0, win32con.KEY_ALL_ACCESS)
    win32api.RegSetValueEx(key, "AccessVBOM", 0, win32con.REG_DWORD, 1)
    

提交回复
热议问题