请大虾帮忙:在word中做好的一个表格,需要向这个表格中的单元格写入数据,不晓得各位有什么好的方法么。
偶看过了很多的搜索到的帖子,都没有搞清楚,另外如何知道word中表格的某个单元格的坐标?先感谢大家了!
偶看过了很多的搜索到的帖子,都没有搞清楚,另外如何知道word中表格的某个单元格的坐标?先感谢大家了!
解决方案 »
- 客户端调用服务端的方法是报错'method ***** not supported by automation object' 自动化对象不支持该方法?怎么回事
- 希望有delphi7编译环境的兄弟帮个忙
- 使用AssingFile关联好一个文件后,有什么办法能够直接定位到文件的最后一行?
- 一个lookup字段问题(帮助说可以,可是我试了不行啊)
- 请问高手,我为什么读出的是空的阿?
- 散分,今天手机离开我10秒又回来了,
- QReport的多列打印问题>...
- 为什么执行thread.free时报错?是不是跟thread的结构有关?
- 消息:凤凰卫视在正播"911惊回首"!!!
- 请问有没有可能代码实现设置mdb的dns啊!给代码就个分!!!
- Dhtml的应用问题!aiirii请进!
- 请高手帮助,数据更新的问题,TKS!
var
StrToAdd : String;
wrdSelection, wrdMailMerge, wrdMergeFields : Variant;
begin
// Create an instance of Word and make it visible
wrdApp := CreateOleObject('Word.Application');
wrdApp.Visible := True;
// Create a new document
wrdDoc := wrdApp.Documents.Add();
wrdDoc.Select; wrdSelection := wrdApp.Selection;
wrdMailMerge := wrdDoc.MailMerge; // Create MailMerge data file
CreateMailMergeDataFile;
// Create a string and insert it into the document
StrToAdd := 'State University' + Chr(13) +
'Electrical Engineering Department';
wrdSelection.ParagraphFormat.Alignment := wdAlignParagraphCenter;
wrdSelection.TypeText(StrToAdd); InsertLines(4); // Insert Merge Data
wrdSelection.ParagraphFormat.Alignment := wdAlignParagraphLeft;
wrdMergeFields := wrdMailMerge.Fields; wrdMergeFields.Add(wrdSelection.Range,'FirstName');
wrdSelection.TypeText(' ');
wrdMergeFields.Add(wrdSelection.Range,'LastName');
wrdSelection.TypeParagraph;
wrdMergeFields.Add(wrdSelection.Range,'Address');
wrdSelection.TypeParagraph;
wrdMergeFields.Add(wrdSelection.Range,'CityStateZip'); InsertLines(2); // Right justify the line and insert a date field with
// the current date
wrdSelection.ParagraphFormat.Alignment := wdAlignParagraphRight;
wrdSelection.InsertDateTime('dddd, MMMM dd, yyyy',False); InsertLines(2); // Justify the rest of the document
wrdSelection.ParagraphFormat.Alignment := wdAlignParagraphJustify; wrdSelection.TypeText('Dear ');
wrdMergeFields.Add(wrdSelection.Range,'FirstName'); wrdSelection.TypeText(',');
FWord.ActiveDocument.Tables.Add(
Range := FWord.Selection.Range,
NumRows := 2, NumColumns := 5,
DefaultTableBehavior := wdWord9TableBehavior,
AutoFitBehavior := wdAutoFitFixed);
FWord.Selection.TypeText(Text:='11');
FWord.ActiveDocument.Tables.Add(
Range := FWord.Selection.Range,
NumRows := 2, NumColumns := 5,
DefaultTableBehavior := wdWord9TableBehavior,
AutoFitBehavior := wdAutoFitFixed);
FWord.Selection.TypeText(Text := '11');
FWord.Selection.MoveRight(unit := wdCell);
FWord.Selection.TypeText(Text := '12');
FWord.Selection.MoveRight(unit := wdCell);
FWord.Selection.TypeText(Text := '13');
FWord.Selection.MoveRight(unit := wdCell);
FWord.Selection.TypeText(Text := '14');
FWord.Selection.MoveRight(unit := wdCell);
FWord.Selection.TypeText(Text := '15');
FWord.Selection.MoveRight(unit := wdCell);
FWord.Selection.TypeText(Text := '21');
FWord.Selection.MoveRight(unit := wdCell);
FWord.Selection.TypeText(Text := '22');
FWord.Selection.MoveRight(unit := wdCell);
FWord.Selection.TypeText(Text := '23');
FWord.Selection.MoveRight(unit := wdCell);
FWord.Selection.TypeText(Text := '24');
FWord.Selection.MoveRight(unit := wdCell);
FWord.Selection.TypeText(Text := '35');
except
on e: Exception do
ShowMessage(e.Message);
end;
end;