Open XLT for edit and set Addin to False

X

XP

Using Office 2003 and Windows XP;

I need to use automation with late binding to open an Excel template (xlt)
for editing AND set its Addin property to false. The code I have so far, with
Tom Ogilvy's help is:

Dim oXL as Object
Dim oWB as Object
Dim sFullName = "fully qualified path to my file.xlt"
Set oXL = CreateObject("Excel.Application")
oxl.EnableEvents = False
Set oWB = oXL.Workbooks.Open(FileName:=sFullName, Editable:=True)

The problem is, since the template's Addin property is set to TRUE you get
an error that an addin cannot be opened for editing.

I suspect this is not possible, but if this is possible, could someone
please post example code and/or correct mine above to deal with it?

Thanks much in advance.
 
T

Tom Ogilvy

If it is an addin, then I wouldn't think it is also a template regardless of
the extension.

Open it as is without the Edit command and it should load as an addin. Or
load it as an addin. Once loaded, you should be able to edit the file with
your code without changing the isAddin property.

this is sample code showing how to load an addin

Sub SolverInstall()
'// Dana DeLouis
Dim wb As Workbook

On Error Resume Next
' Set a Reference to the workbook that will hold Solver
Set wb = ActiveWorkbook

With wb.VBProject.References
.Remove .Item("SOLVER")
End With

With AddIns("Solver Add-In")
.Installed = False
.Installed = True
wb.VBProject.References.AddFromFile .FullName
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top