VBA中的宏Sub GetPptText()
Dim m, n, i, j As Integer
Dim s As String n = ActiveWindow.Presentation.Slides.Count
For i = 1 To n
m = ActiveWindow.Presentation.Slides(i).Shapes.Count
For j = 1 To m
If ActiveWindow.Presentation.Slides(i).Shapes(j).HasTextFrame Then
s = s & ActiveWindow.Presentation.Slides(i).Shapes(j).TextFrame.TextRange.Text & "|"
End If
Next
Next MsgBox s
End Subdelphi代码
function ReadPPt(sName: string): string;
var
n,m,i,j: integer;
PptApp: OleVariant;
begin
try
PptApp := CreateOleObject('PowerPoint.Application');
PptApp.Visible := true; PptApp.Presentations.Open(sName);
n := PptApp.ActiveWindow.Presentation.Slides.Count; for i:=1 to n do
begin
m := PptApp.ActiveWindow.Presentation.Slides(i).Shapes.Count;//这里提示对象没有找到
for j:=1 to m do
begin
If PptApp.ActiveWindow.Presentation.Slides(i).Shapes(j).HasTextFrame Then
result := PptApp.ActiveWindow.Presentation.Slides(i).Shapes(j).TextFrame.TextRange.Text +#$D#$A;
end;
end; finally
PptApp.Presentation.Saved := true;
PptApp.Presentation.Close;
PptApp.Quit;
PptApp := null;
end;
end;delphi提取ppt文件里的文本函数,VBA中能正确执行,但delphi中提示出错。哪位写过类似程序的朋友,看看,问题处在哪里?
Dim m, n, i, j As Integer
Dim s As String n = ActiveWindow.Presentation.Slides.Count
For i = 1 To n
m = ActiveWindow.Presentation.Slides(i).Shapes.Count
For j = 1 To m
If ActiveWindow.Presentation.Slides(i).Shapes(j).HasTextFrame Then
s = s & ActiveWindow.Presentation.Slides(i).Shapes(j).TextFrame.TextRange.Text & "|"
End If
Next
Next MsgBox s
End Subdelphi代码
function ReadPPt(sName: string): string;
var
n,m,i,j: integer;
PptApp: OleVariant;
begin
try
PptApp := CreateOleObject('PowerPoint.Application');
PptApp.Visible := true; PptApp.Presentations.Open(sName);
n := PptApp.ActiveWindow.Presentation.Slides.Count; for i:=1 to n do
begin
m := PptApp.ActiveWindow.Presentation.Slides(i).Shapes.Count;//这里提示对象没有找到
for j:=1 to m do
begin
If PptApp.ActiveWindow.Presentation.Slides(i).Shapes(j).HasTextFrame Then
result := PptApp.ActiveWindow.Presentation.Slides(i).Shapes(j).TextFrame.TextRange.Text +#$D#$A;
end;
end; finally
PptApp.Presentation.Saved := true;
PptApp.Presentation.Close;
PptApp.Quit;
PptApp := null;
end;
end;delphi提取ppt文件里的文本函数,VBA中能正确执行,但delphi中提示出错。哪位写过类似程序的朋友,看看,问题处在哪里?
解决方案 »
- 怎样通过Delphi来调用Outlook发送任务通知消息?
- 请问,如何打开.BAT的文件?
- 如何将EXCEL,ACCESS,FORPRO等数据库导入到SQL—SERVER数据库中。
- 标准菜单图标的尺寸是多大?
- 如何禁mediaplayer中的声音?
- #######怎样写屏幕保护程序?要保证能加入密码。#######
- 寻求vclzip控件源代码,版本2.0以上.(在线等待..)
- 难到这个问题没人回答吗?????http://www.csdn.net/Expert/topic/430/430088.shtm
- 热心肠的大虾请进来:)
- 我买了一本《DELPHI 5.0开发人员指南>>,我为大家做什么??(的确是一本难得的好书)
- 如何用自己软件向WORD,TXT文件输入内容
- 帮我查看代码有什么问题?
如:ActiveWindow.Presentation.Slides.Item(i).Shapes.Item(j).TextFrame参考一下Servers页的TPowerPointApplication控件的属性和方法
如:ActiveWindow.Presentation.Slides.Item(i).Shapes.Item(j).TextFrame 参考一下Servers页的TPowerPointApplication控件的属性和方法up
up
var
n,m,i,j: integer;
PptApp: OleVariant;
begin
try
PptApp := CreateOleObject('PowerPoint.Application');
PptApp.Visible := true; PptApp.Presentations.Open(sName);
n := PptApp.ActiveWindow.Presentation.Slides.Count; for i:=1 to n do
begin
m := PptApp.ActiveWindow.Presentation.Slides.item(i).Shapes.Count;
for j:=1 to m do
begin
If PptApp.ActiveWindow.Presentation.Slides.item(i).Shapes.item(j).HasTextFrame Then
result:=result+PptApp.ActiveWindow.Presentation.Slides.item(i).Shapes.item(j).TextFrame.TextRange.Text +#$D#$A;
end;
end; PptApp.ActiveWindow.Presentation.Saved := true;
PptApp.ActiveWindow.Close;
except
result := '';
end;
end;
var
n,m,i,j: integer;
PptApp: OleVariant;
begin
try
PptApp := CreateOleObject('PowerPoint.Application');
PptApp.Visible := true; PptApp.Presentations.Open(sName);
n := PptApp.ActiveWindow.Presentation.Slides.Count; for i:=1 to n do
begin
m := PptApp.ActiveWindow.Presentation.Slides.item(i).Shapes.Count;
for j:=1 to m do
begin
If PptApp.ActiveWindow.Presentation.Slides.item(i).Shapes.item(j).HasTextFrame Then
result:=result+PptApp.ActiveWindow.Presentation.Slides.item(i).Shapes.item(j).TextFrame.TextRange.Text +#$D#$A;
end;
end; PptApp.ActiveWindow.Presentation.Saved := true;
PptApp.ActiveWindow.Close;
except
result := '';
end;
end;
我的软件也写好了,用这个软件可以自动读取目录下的doc,ppt,各类文本等格式的文件内容,然后生成html页面。主要目的就是做个资源共享的网站,现在我把网站挂上去了。地址是:http://www.mflwk.cn/