Create Powerpoint presentation from Delphi (Oleobject)

Asked

Viewed 258 times

0

I’m trying to generate a Powerpoint presentation from a Memo, I found a code on the internet that uses Oleobject, but it’s not working.

What is incorrect? (I use Delphi 10.2 Tokyo)

uses
System.Win.ComObj

Procedure:

procedure EnviarparaPowerPoint;
var
PowerPointApp: OLEVariant;
begin
try
PowerPointApp := CreateOleObject('PowerPoint.Application');
PowerPointApp.Visible := True;
PowerPointApp.Presentations.Add;
except
Application.MessageBox('Aconteceu um erro na conversão para o PowerPoint !!!',
'Erro', MB_OK + MB_ICONHAND + MB_DEFBUTTON1 + MB_APPLMODAL);
end;

Screen.Cursor := crHourGlass;

begin
//Incluir Slide
PowerPointApp.ActivePresentation.Slides.Add(1, 11); //11 é igual a ppLayoutTitleOnly
    
// Editar o titulo do slide
PowerPointApp.ActiveWindow.Selection.SlideRange.Shapes('Rectangle 2').Select;
PowerPointApp.ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select;
PowerPointApp.ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(
Start := 1, Length := 0).Select;

PowerPointApp.ActiveWindow.Selection.TextRange.Text := Memo1.Lines.Text;
PowerPointApp.ActiveWindow.Selection.TextRange.Font.Name := 'Arial';
PowerPointApp.ActiveWindow.Selection.TextRange.Font.Size := 30;
PowerPointApp.ActiveWindow.Selection.TextRange.Font.Bold := msoFalse;
PowerPointApp.ActiveWindow.Selection.TextRange.Font.Italic := msoFalse;
PowerPointApp.ActiveWindow.Selection.TextRange.Font.Underline := msoFalse;
PowerPointApp.ActiveWindow.Selection.TextRange.Font.Shadow := msoFalse;
PowerPointApp.ActiveWindow.Selection.TextRange.Font.Emboss := msoFalse;
PowerPointApp.ActiveWindow.Selection.TextRange.Font.BaselineOffset := 0;
PowerPointApp.ActiveWindow.Selection.TextRange.Font.AutoRotateNumbers := msoFalse;
PowerPointApp.ActiveWindow.Selection.TextRange.Font.Color.SchemeColor := ppTitle;
end;
end;

Mistakes:

Undeclared Identifier: 'ppLayoutTitleOnly'

Undeclared Identifier: 'msoFalse'

Undeclared Identifier: 'ppTitle'

  • You could specify what is not working. Error code?

  • You have Powerpoint installed on your machine?

  • @Wellingtontellescunha Added errors to question.

  • @Marcelouchimura Yes, Powerpoint is installed on the machine. However as it will be a software that will be distributed to several users I will have to check if Powerpoint is installed on the machine.

1 answer

1


  • Thank you. It’s almost working. My code has compiled, but it has a lot of problems.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.