rebol [ Title: "Word formatted table" File: %word-formatted-table.r Date: 29-Jun-2006 Version: 1.0.0 Progress: 0.5 Status: "working" Needs: [] Author: "Anton Rolls" Language: "English" Purpose: {Add a formatted table to a Word document.} Usage: {} History: [ 1.0.0 [29-Jun-2006 {First version, converted from Benjamin's code} "Anton"] ] ToDo: { - find the original C sample if there is one - can be optimized significantly } Notes: {} ] if error? set/any 'error try [ ; catch all errors do/args %../COMLib.r [ ; Use the COMLib API functions here word_obj: createObject "Word.Application" PutValue [word_obj ".Visible = %s" "TRUE"] word_doc: GetObject [word_obj ".Documents.Add"] objRange: GetObject [word_doc ".Range()"] CallMethod [word_doc ".Tables.Add %o, %d, %d" objRange 1 3] objTable: GetObject [word_doc ".Tables(%d)" 1] ;CallMethod [objTable ".Rows.Add" ""] ;CallMethod [objTable ".Rows.Add" ""] ;CallMethod [objTable ".Rows.Add" ""] ; ; ;PutValue [objTable ".Cell(%d,%d).Range.Font.Bold = %d" 1 1 1] ;PutValue [objTable ".Cell(%d,%d).Range.Font.Name = %s" 1 1 "Verdana"] ;PutValue [objTable ".Cell(%d,%d).Range.Font.Size = %d" 1 1 12] ;PutValue [objTable ".Cell(%d,%d).Range.text = %s" 1 1 "HOLAXXXX"] repeat n 10 [ CallMethod [objTable ".Rows.Add"] PutValue [objTable ".Cell(%d,%d).Range.Font.Bold = %d" n 1 1] PutValue [objTable ".Cell(%d,%d).Range.Font.Name = %s" n 1 "Verdana"]; PutValue [objTable ".Cell(%d,%d).Range.Font.Size = %d" n 1 (20 - n)] PutValue [objTable ".Cell(%d,%d).Range.text = %s" n 1 rejoin ["num: " n]] PutValue [objTable ".Cell(%d,%d).Range.text = %s" n 2 rejoin ["cel: " n]] PutValue [objTable ".Cell(%d,%d).Range.text = %s" n 3 rejoin ["cel: " n]] ] release objTable release objRange release word_doc release word_obj ] ][ print mold disarm error ]