DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

tdm excel automation

Solved!
Go to solution

Hey there,

I got a script that creates *.TDM files. The annoying part is that i have to right click everytime on the created file to convert it with the TDM EXCEL ADD INN and save it with the same name like the created *.TDM file.

So, I wanted to implement it in my script but it doesn´t work.

There a piece of code i found here in the Community but in the line which says "oComAddIn.connect = True" occurs an error.

Dim oExcel

Dim oComAddIn

 

Set oExcel = CreateObject("Excel.Application")

 

For Each oComAddIn In oExcel.COMAddIns

 

If oComAddIn.ProgId = "ExcelTDM.TDMAddin"Then

oComAddIn.connect =True

IfNot oComAddIn.Object IsNothingThen' use the object interface here

Else

MsgBox"No object interface available! :-((("

EndIf

EndIf

Next

 

I´m very thankful for every help.

 

0 Kudos
Message 1 of 5
(6,100 Views)

Hi,

you do not have to loop over all COMAddIns, simply use the Item() Method for COMAddIns to get the AddIn you want.

The oComAddin.connect = True is only necessarry if called from within Excel.

 

The following code should work as expected

Dim oExcel
Dim oComAddIn
Dim myBasePath : myBasePath = "C:\data\"
Dim myFilename : myFilename = "MyFilename"

Set oExcel = CreateObject("Excel.Application")
Set oComAddIn = oExcel.Application.COMAddIns.Item("ExcelTDM.TDMAddin") 

oComAddIn.Object.ImportFile myBasePath & myFilename & ".tdm"
oExcel.Application.Workbooks(1).SaveAs myBasePath & myFilename & ".xlsx"

 

Hope this helps

0 Kudos
Message 2 of 5
(6,096 Views)

Hey,

thank you very very much. It works but it occured another problem.

I try to open the file and it opens itself twice. One file has no name, the other file has the desired name but it is in the read only mode.

When i try to delete all it´s not possible because Windows thinks it has acces to this new file.

 

Can you help me in this case again?

 

0 Kudos
Message 3 of 5
(6,089 Views)
Solution
Accepted by Dredg042

After running the script, please take a look into the task manager of Windows. Is Excel still running?

If yes, the following lines should close Excel at the end of the script:

 

oExcel.Application.Quit
Set oComAddIn = Nothing
Set oExcel = Nothing

 

Message 4 of 5
(6,085 Views)

Thank you sooo much!!!!

0 Kudos
Message 5 of 5
(6,081 Views)