|
You refer to the following code to write the content of dw to word:
constant integer ppLayoutBlank = 12
OLEObject ole_object
ole_object = Create OLEObject
if ole_object.ConnectToNewObject ("Word.Application") <> 0 then
MessageBox ("Caption", "Connect error")
return
end if
ole_object.Visible = true
long ll_cols, ll_rows
constant long wdWord9TableBehavior = 1
constant long wdAutoFitFixed = 0
constant long wdCell = 12
string lsvalue
ll_cols = long (dw_1.object.datawindow.column.count)
ll_rows = dw_1.RowCount ()
ole_object.Documents.Add ()
ole_object.ActiveDocument.Tables.Add (ole_object.Selection.Range, ll_rows, ll_cols)
string ls_colname, ls_value
integer i, j
for i = 1 to ll_cols
ls_colname = dw_1.Describe ("#" + string (i) + ".name") + "_t"
ls_value = dw_1.Describe (ls_colname + ".text")
ole_object.Selection.TypeText (trim (ls_value))
ole_object.Selection.MoveRight (wdCell)
next
dw_1.SetRedraw (false)
ole_object.Selection.MoveLeft (wdCell)
for i = 2 to ll_rows
for j = 1 to ll_cols
dw_1.ScrollToRow (i-1)
dw_1.SetColumn (j)
ls_value = dw_1.GetText ()
ole_object.Selection.MoveRight (wdCell)
ole_object.Selection.TypeText (ls_value)
next
next
dw_1.SetRedraw (true)
constant long wdFormatDocument = 0
//ole_object.ActiveDocument.SaveAs("sample.doc",0,false,true,false,false,false,false,false)
ole_object.DisConnectObject ()
destroy ole_object |
|