Как работать с Powerpoint через OLE?
Falk0ner, вс, 06/07/2008 - 15:35.
uses
comobj;
procedure TForm1.Button2Click(Sender: TObject);
var
PowerPointApp: OLEVariant;
begin
try
PowerPointApp := CreateOleObject('PowerPoint.Application');
except
ShowMessage('Error...');
Exit;
end;
// Make Powerpoint visible
PowerPointApp.Visible := True;
// Show powerpoint version
ShowMessage(Format('Powerpoint version: %s',[PowerPointApp.Version]));
// Open a presentation
PowerPointApp.Presentations.Open('c:\MyPresentation.ppt', False, False, True);
// Show number of slides
ShowMessage(Format('%s slides.',[PowerPointApp.ActivePresentation.Slides.Count]));
// Run the presentation
PowerPointApp.ActivePresentation.SlideShowSettings.Run;
// Go to next slide
PowerPointApp.ActivePresentation.SlideShowWindow.View.;
// Go to slide 2
PowerPointApp.ActivePresentation.SlideShowWindow.View.GoToSlide(2);
// Go to previous slide
PowerPointApp.ActivePresentation.SlideShowWindow.View.;
// Go to last slide
PowerPointApp.ActivePresentation.SlideShowWindow.View.Last;
// Show current slide name
ShowMessage(Format('Current slidename: %s',[PowerPointApp.ActivePresentation.SlideShowWindow.View.Slide.Name]));
// Close Powerpoint
PowerPointApp.Quit;
PowerPointApp := UnAssigned;
end;
comobj;
procedure TForm1.Button2Click(Sender: TObject);
var
PowerPointApp: OLEVariant;
begin
try
PowerPointApp := CreateOleObject('PowerPoint.Application');
except
ShowMessage('Error...');
Exit;
end;
// Make Powerpoint visible
PowerPointApp.Visible := True;
// Show powerpoint version
ShowMessage(Format('Powerpoint version: %s',[PowerPointApp.Version]));
// Open a presentation
PowerPointApp.Presentations.Open('c:\MyPresentation.ppt', False, False, True);
// Show number of slides
ShowMessage(Format('%s slides.',[PowerPointApp.ActivePresentation.Slides.Count]));
// Run the presentation
PowerPointApp.ActivePresentation.SlideShowSettings.Run;
// Go to next slide
PowerPointApp.ActivePresentation.SlideShowWindow.View.;
// Go to slide 2
PowerPointApp.ActivePresentation.SlideShowWindow.View.GoToSlide(2);
// Go to previous slide
PowerPointApp.ActivePresentation.SlideShowWindow.View.;
// Go to last slide
PowerPointApp.ActivePresentation.SlideShowWindow.View.Last;
// Show current slide name
ShowMessage(Format('Current slidename: %s',[PowerPointApp.ActivePresentation.SlideShowWindow.View.Slide.Name]));
// Close Powerpoint
PowerPointApp.Quit;
PowerPointApp := UnAssigned;
end;
Взято с сайта http://www.swissdelphicenter.ch/en/tipsindex.php
Ничего не понятно))))
короче, сначала прописывается
потом var PowerPointApp: OLEVariant;
далее
try
PowerPointApp := CreateOleObject('PowerPoint.Application');
except
ShowMessage('Error...');
Exit;
end;
PowerPointApp.Visible := True;
для открытия PowerPointApp.Presentations.Open('<имя файла>', False, False, True);
для просмотра PowerPointApp.ActivePresentation.SlideShowSettings.Run;
туда,сюда,обратно по слайдам:
PowerPointApp.ActivePresentation.SlideShowWindow.View.next;
PowerPointApp.ActivePresentation.SlideShowWindow.View.previous;
PowerPointApp.ActivePresentation.SlideShowWindow.View.GoToSlide(2);
PowerPointApp.ActivePresentation.SlideShowWindow.View.Last;
PowerPointApp.Quit;
сломать все нах*йPowerPointApp := UnAssigned;
Подскажите как создать на слайте таблицу (X столбцов и Y строк) и внести в определенную ячейку текст!! Очень нужно!!
Отправить комментарий