'Edit xltm file with macro without .vba file

I have been given a .xltm file which has template, data and macros. The earlier developer has lost the the .vba file. I wanted to debug and make changes in macro which automatically close excel the moment I open it. Stuggling to work arround the situation for last one week.

Is there any way, I can open the excel file without executing a macro and then edit and save them? What is the way as I don't have .vba file. Or is there any tool which can generate the .vba file from .xmlt and allow me to debug, edit and save in tool like Visula studio.

Help deperatly needed.



Solution 1:[1]

This will open the template in edit mode, and suppress any auto-run macros it might contain:

Sub Test()
    Dim z As Workbook, sec
    sec = Application.AutomationSecurity 'store current state
    Application.AutomationSecurity = msoAutomationSecurityForceDisable
    Set z = Workbooks.Open("C:\Excel\Temp\Tester.xltm", editable:=True)
    Application.AutomationSecurity = sec
End Sub

Not sure what you mean by ".vba file" though. VBA is embedded in the xltm file and is not editable seaprately from that file. You can't use VS to debug VBA code - you need to use the Excel VB editor for that.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1