PowerPoint.Application and OLE2

J

Jack

How to edit TextFrame in PowerPoint?
Below does open presentetion, but does not edit that text.
Any ideas?


application:=OLE2.CREATE_OBJ('PowerPoint.Application');
OLE2.SET_PROPERTY(application, 'Visible', 1);
-- Return object handle to the Presentations collection
presentations:=OLE2.GET_OBJ_PROPERTY(application, 'Presentations');

x_paikka := 30;
-- Open the required Presentation
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, x_dir||'\Test.ppt');
ole2.add_arg(args,0);
presentation := ole2.invoke_OBJ(presentations,'Open', args);
ole2.destroy_arglist(args);

x_paikka := 60;
-- VB macro
-- ActiveWindow.Selection.SlideRange.Shapes("Text Box 29").Select
-- ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select
--
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=5,
Length:=7).Select
-- ActiveWindow.Selection.TextRange.Text = "36 745"
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 'Text Box 29');
slides := OLE2.GET_OBJ_PROPERTY(presentation, 'SlideRange', args);
OLE2.SET_PROPERTY(slides, 'Value', '36 745');
OLE2.DESTROY_ARGLIST(args);
 
S

Steve Rindsberg

How to edit TextFrame in PowerPoint?
Below does open presentetion, but does not edit that text.
Any ideas?

application:=OLE2.CREATE_OBJ('PowerPoint.Application');
OLE2.SET_PROPERTY(application, 'Visible', 1);
-- Return object handle to the Presentations collection
presentations:=OLE2.GET_OBJ_PROPERTY(application, 'Presentations');

x_paikka := 30;
-- Open the required Presentation
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, x_dir||'\Test.ppt');
ole2.add_arg(args,0);
presentation := ole2.invoke_OBJ(presentations,'Open', args);
ole2.destroy_arglist(args);

x_paikka := 60;
-- VB macro
-- ActiveWindow.Selection.SlideRange.Shapes("Text Box 29").Select
-- ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select

This would select an existing text box and substitute "36 745" in place of the
existing characters 5 - 12, I think.

But it all depends on the selection that the user's already made, and that
won't happen when you're automating PPT.

A better VBA model to translate might be:

ActivePresentation.Slides(x).Shapes("Text Box
29").TextFrame.TextRange.Characters(5,12).Text = "36 745"

This assumes that you know the SlideIndex of the slide you want to work with (x
above) and that there is a shape named "Text Box 29" on the slide.
 
J

Jack

Steve Rindsberg said:
This would select an existing text box and substitute "36 745" in place of
the
existing characters 5 - 12, I think.

But it all depends on the selection that the user's already made, and that
won't happen when you're automating PPT.

A better VBA model to translate might be:

ActivePresentation.Slides(x).Shapes("Text Box
29").TextFrame.TextRange.Characters(5,12).Text = "36 745"

This assumes that you know the SlideIndex of the slide you want to work
with (x
above) and that there is a shape named "Text Box 29" on the slide.


--
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
Hi!

Thanks for your advice.

I can get handle to to ActivePresentation.
aPresentation := OLE2.GET_OBJ_PROPERTY(application, 'ActivePresentation');

But how to get that slide(1)?
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, '1');
slide := OLE2.GET_OBJ_PROPERTY(aPresentation, 'Slides', args);
This does not work either slide := OLE2.INVOKE_OBJ(aPresentation, 'Slides',
args);

Or is there some better way to get handle direct with object name?

Jack
 
S

Steve Rindsberg

[snip snip]
Hi!

Thanks for your advice.

I can get handle to to ActivePresentation.
aPresentation := OLE2.GET_OBJ_PROPERTY(application, 'ActivePresentation');

But how to get that slide(1)?
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, '1');
slide := OLE2.GET_OBJ_PROPERTY(aPresentation, 'Slides', args);
This does not work either slide := OLE2.INVOKE_OBJ(aPresentation, 'Slides',
args);

Or is there some better way to get handle direct with object name?

I don't speak C (with or without plus or minus signs) so I can't help with
that, sorry.

But in case this helps:

The Presentation object's Slides property returns a Slides collection into
which you can index to get the slide you want.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top