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?
– Wellington Telles Cunha
You have Powerpoint installed on your machine?
– Marcelo Shiniti Uchimura
@Wellingtontellescunha Added errors to question.
– lukkicode
@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.
– lukkicode