TurboCAD Forums

The Ultimate Resource for TurboCAD Knowledge

Register
 
Remember to do a search before you ask a question!!!

TC19-64 and Excel2002
Read 1700 times
* July 16, 2012, 09:46:07 AM
creating an .exe to read and write Data from TC to Excel.
Although the Debugger mention error, the .exe runs and works fine.

Using the template VS2010-TC19-64_exe.zip
http://forums.turbocad.com/index.php/topic,8840.0.html

reference
Excel
(Imsigx is already in the template)

In this example TC19-64 and excel2002 is already running.
The TC-tools will be written in the spreadsheet.
This .exe doesn´t make much sense, because VB.net is not able to start the TC-tools. At least I don´t know how to do that.
But the example shows how to bring Data from TC2Excel. Vice versa works also fine.

I had no success to build a .dll. (using GetObject(, "Excel.Application"))

best regards
Bernd

code:
===================================================

    Sub Main()
        '*********************************************************
        'Achtung: Debuggmodus funktioniert nicht, gibt fehler bei COM aus
        ' die .exe läuft aber
        '*************************************
        Dim tcapp As New IMSIGX.Application
        Dim actdr As IMSIGX.Drawing
        actdr = tcapp.ActiveDrawing
        Dim i As Integer

        Dim appExcel As Object
        Dim wbook As Object
        Dim wsheet As Object
        Try
            appExcel = GetObject(, "Excel.Application")
            wbook = appExcel.ActiveWorkbook
            wsheet = appExcel.ActiveSheet()

        Catch
            MsgBox(" Open Excel error. Is Excel Open?", vbExclamation, "Error" & Err.Number & " " & Err.Description)
            wsheet = Nothing
            wbook = Nothing
            appExcel = Nothing
            Exit Sub

        End Try

 
        Try
            For i = 1 To actdr.Application.Tools.Count - 1
                wsheet.Cells(i, 1) = i
                wsheet.Cells(i, 2) = actdr.Application.Tools(i).MenuText
                wsheet.Cells(i, 3) = actdr.Application.Tools(i).ID
                'Debug.Print(actdr.Application.Tools(i).Index)
            Next i

 

        Catch
            MsgBox(" Excel error. Excel Opened but didn't write", vbExclamation, "Error" & Err.Number & " " & Err.Description)
        End Try
        'try to start a tool with VB.net
        'tcapp.Tools(33000).Activate()  ' don´t work


    End Sub

========================================



Logged