TCOM: how to access Excell worksheets with tcom 
Author Message
 TCOM: how to access Excell worksheets with tcom

Hi

I have been experimenting with tcom. So far I was able to access a table
within a worksheet. It works ok as long as I know the name of a worksheet.
But: how can I access a worksheet without knowing the name of it?

In the exampe bellow the command [$tab2 Name] returns the name of the
worksheet (which may be modified by the user). The command [$tab2 CodeName]
returns the internal table name. All I want is to acces the table trough the
internal name or to receive a list of table names within a worksheet

appreciate your help

Stefan

Example:

    set application [::tcom::bind "Excel.Application"]
    $application Visible 1

    set workbooks [$application Workbooks]

    # open xls file
    set workbook [$workbooks Open {c:\test.xls}]

    set worksheets [$workbook Worksheets]

    # get access to table sheet 2
    set tab2 [$worksheets Item "Table2"]



Thu, 11 Apr 2002 03:00:00 GMT  
 TCOM: how to access Excell worksheets with tcom

Quote:

>All I want is to acces the table trough the
>internal name or to receive a list of table names within a worksheet

I just updated tcom to allow the following example script to work.
You need to download version 1.9 from the http://www.vex.net/~cthuang/tcom/
page.

    package require tcom

    set application [::tcom::bind "Excel.Application"]
    $application Visible 1

    set workbooks [$application Workbooks]

    # open xls file
    set workbook [$workbooks Open {c:\test.xls}]

    set worksheets [$workbook Worksheets]

    # Output names of worksheets.
    set numWorksheets [$worksheets Count]
    for {set i 1} {$i <= $numWorksheets} {incr i} {
        set worksheet [$worksheets Item $i]
        puts [$worksheet Name]
        ::tcom::release $worksheet
    }

    ::tcom::release $worksheets $workbook $workbooks $application



Sat, 13 Apr 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Adding new excel worksheet with tcom

2. TCOM: Using tcom to create a Hyperlink in Excel

3. Accessing Windows explorer with optcl or tcom

4. Problem accessing a method through TCOM v1.8

5. ANNOUNCE: tcom 1.8 -- Access and implement Windows COM objects in Tcl

6. filename length in TCOM

7. help wanted: F-PC -> TCOM

8. File Handling in TCOM

9. F-PC, TCOM and Win32Forth

10. help wanted: F-PC -> TCOM

11. TCOM and DOS memory allocation

12. TCOM bug?

 

 
Powered by phpBB® Forum Software