gpt4 book ai didi

vba - Delphi 中的 PowerPoint : fill table with text

转载 作者:行者123 更新时间:2023-12-03 15:54:47 25 4
gpt4 key购买 nike

我正在 Dephi XE3 中编写 PowerPoint 的插件,它将插入一个表格并填充一些文本。我快完成了,但我无法用文本填充表格。

这是我的代码:

insp:=CreateOleObject('PowerPoint.Application');
insp.ActivePresentation.Slides.Add(1, ppLayoutBlank);
MSTable:=insp.ActivePresentation.Slides.Item(1);
MSTable.Shapes.AddTable(5, 5, 100, 0);
MSTable.Table.Cell(2,2).Shape.TextFrame.TextRange.Text:='Text';

当我尝试填充表格时,出现此错误

Method 'Table' not supported by automation object

也尝试过这个:

MSTable.AddTable(5, 5, 100, 0).Cell(2,2).Shape.TextFrame.TextRange.Text:='Text';
MSTable.Table.Item(1).Cell(2,2).Shape.TextFrame.TextRange.Text:='Text';

在 MSDN 上找到了如何用 VBA 编写此代码,但没有帮助。请帮我解决这个问题。

最佳答案

已关注此MSDN example这就是您创建和访问 PowerPoint-table

的方式
var
LApp, LSlide, LTable : Variant;
begin
LApp := CreateOleObject( 'PowerPoint.Application' );
LSlide := LApp.ActivePresentation.Slides.Add( 1, ppLayoutBlank );
LTable := LSlide.Shapes.AddTable( 5, 5, 100, 0 ).Table;

LTable.Cell( 2, 2 ).Shape.TextFrame.TextRange.Text := 'Text';

关于vba - Delphi 中的 PowerPoint : fill table with text,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18052566/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com