当前位置:主页>仓库管理软件> 列表

word问题。大家看看好吗? 找速达3000软件狗

财务软件版1楼: CreateOleObject启动Word
word中表格是怎样控制长、高、格式、边框设为无等。
Selection.Tables(1).Rows.Height = CentimetersToPoints(12)
Selection.Tables(1).Borders(wdBorderLeft).LineStyle = wdLineStyleNone
这样写delphi说不支持LineStyle,CentimetersToPoints方法
怎样控制插入图片的格式如大小等。
Selection.InlineShapes(1).Height = 128.39
Selection.InlineShapes(1).Width = 192.44
这样写delphi说不支持InlineShapes方法
网上的文章不是有说过CreateOleObject方式是最继灵活的控制word的方法吗?
word中的域怎样用?
最好还是给出代码吧。

2楼: 去看word的vba帮助,重点注意item、range的用法。控制word代码不难就是很烦。 如速达3000软件狗

3楼: 你录制一点宏,然后看vba代码

4楼: 写过EXCEL,WORD表格没有使用过。想必大同小异。

5楼: 用richviewedit控件啊

6楼: 看VBA帮助啊,或者录制宏啊。
我这里有一段:
var
FWordFile:OleVariant;
OleFindText,OleForword,OleReplaceText,OleRelaceOption:OleVariant;
Password:OleVariant;
FTable:Table;
FUnit,FCount,FExtent:OleVariant;
FRow,I:integer;
FCommandBarName:OleVariant;
FCommandBar:OleVariant;
FCodeNameNo:String;
begin
Screen.Cursor:=crHourGlass;
if not DM.SaveToDocTemplet(DM.QWord,FileName) then Exit;
//开启WORD2000
Word2000.Disconnect;
try
Word2000.Connect;
except
ErrMessage(''RPC远程接口出错!强烈建议去除杀毒软件的嵌入模式。'');
Word2000.Disconnect;
Abort;
end;
FTable:=Word2000.Selection.Tables.Add(Word2000.Selection.Range,FRowCount+1,5,
EmptyParam,EmptyParam);
FTable.Range.Font.Name:=''宋体'';FTable.Range.Font.Size:=9;
with FTable do
begin
//----------设定表格边框--------
Borders.Item(wdBorderLeft).LineStyle:=wdLineStyleNone;
Borders.Item(wdBorderRight).LineStyle:=wdLineStyleNone;
Borders.Item(wdBorderTop).LineStyle:=wdLineStyleNone;
Borders.Item(wdBorderBottom).LineStyle:=wdLineStyleNone;


Borders.Item(wdBorderHorizontal).LineStyle:=wdLineStyleNone;
Borders.Item(wdBorderVertical).LineStyle:=wdLineStyleNone;
Borders.Item(wdBorderDiagonalDown).LineStyle:=wdLineStyleNone;
Borders.Item(wdBorderDiagonalUp).LineStyle:=wdLineStyleNone;
Borders.Shadow:=False;
//------设置表格对齐方式---------------
FTable.Columns.PreferredWidthType:=wdPreferredWidthAuto;
FTable.Range.ParagraphFormat.Alignment:=wdAlignParagraphCenter;
Word2000.Selection.Cells.VerticalAlignment:=wdCellAlignVerticalCenter;
//----------设定表格标题-------------
Cell(1,1).Range.Font.Name:=''宋体''; Cell(1,1).Range.Font.Size:=9;
Cell(1,1).Range.Text:=''名称'';
Cell(1,2).Range.Font.Name:=''宋体''; Cell(1,2).Range.Font.Size:=9;
........................................................
//------------------填写数据-------------
FRow:=2;
for I:=1 to StoreGrid.RowCount-1 do
begin
if StoreGrid.Cells[0,I]<>'''' then
begin
Cell(FRow,1).Range.Text:=StoreGrid.Cells[1,I];
Cell(FRow,2).Range.Text:=StoreGrid.Cells[2,I];
....................
FRow:=FRow+1;
end;
end;//end table
end;
我使用的是wordapplication,不过和OLE一样代码。

财务软件版7楼: 我用wordapplication解决了问题。但OLE的代码怎么写呢。谢谢大家

8楼: 多人接受答案了。