daisy4u721
Programmer
I have a code that creates a MS word file with tables using tcom package. I am trying to insert some text from sql database into the columns and rows, ive being trying different codes and its doesnt seem to work, any help please? The code is below:
This code creates a 3 rows and 3 columns table
What im trying to do is insert text from sql under title and i tried this code but its giving me a "TYPE Mismatch" error.
Does anyone have any idea why its giving me this error?
Any help will be appreciated. I have been on this for the past 2 weeks.
Thanks.
This code creates a 3 rows and 3 columns table
Code:
package require tcom
set application [::tcom::ref createobject "Word.Application"]
$application Visible 1
$application DisplayAlerts 0
set docs [$application Documents]
set doc [$docs Add ]
set unit 12
[$doc Tables] Add [[$application Selection] Range] [set NumRows 3] [set NumColumns 3]
[$::application Selection] TypeText "Title"
[$::application Selection] MoveRight $unit 1
[$::application Selection] TypeText "Date"
[$::application Selection] MoveRight $unit 1
[$::application Selection] TypeText "Number"
[$::application Selection] MoveRight $unit 1
What im trying to do is insert text from sql under title and i tried this code but its giving me a "TYPE Mismatch" error.
Code:
set query "Select title From table"
set foo [sql $query]
[$::application Selection] TypeText "$foo"
Does anyone have any idea why its giving me this error?
Any help will be appreciated. I have been on this for the past 2 weeks.
Thanks.