pb生成word文档代码

生成WORK按钮代码:
constant integer pplayoutblank=12
oleobject ole_object
ole_object=create oleobject

//连接到powerpoint
if ole_object.connecttonewobject(word.application)<>0 then
   messagebox('OLE错误','OLE无法连接!')
   return
end if

ole_object.visible=true
long ll_colnum,ll_rownum
constant long wdWord9TableBehavior=1
constant long wdAutoFitFixed=0
constant long wdCell=12
string ls_value
//得到数据窗口数据的列数与行数
ll_colnum=long(dw_1.object.datawindow.column.count)
ll_rownum=dw_1.rowcount()+1
ole_object.Documents.Add()
ole_object.ActiveDocument.Tables.Add(ole_object.Selection.Range,ll_rownum,ll_colnum)
string ls_colname
integer i,j
for i=1 to ll_colnum
//得到标题头的名字
    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_rownum
    for j=1 to ll_colnum
        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连接
ole_object.disconnectobject()
destroy ole_object
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值