Translation of VBA PowerPoint code in Delphi, "keep source formatting"

I work with Delphi (2010), but I'm new to PowerPoint (2010)

I found two codes for copying slides with "keep original formatting":

Sub test1() Dim orig_slide, new_slide As Slide Dim slide_range As SlideRange Set orig_slide = ActivePresentation.Slides(2) orig_slide.Copy Set slide_range = ActivePresentation.Slides.Paste(6) Set new_slide = slide_range.Item(1) new_slide.Design = orig_slide.Design new_slide.ColorScheme = orig_slide.ColorScheme End Sub Sub test2() ActivePresentation.Slides(2).Select ActiveWindow.Selection.Copy ActiveWindow.View.PasteSpecial (DataType = ppPasteOLEObject) End Sub 

Both of them give the desired results in PowerPoint, but in Delphi I get exceptions:

test1 line

 new_slide.Design = orig_slide.Design 

EOleSysError exception class with the message 'Member not found'

test2 line

 ActiveWindow.View.PasteSpecial (DataType = ppPasteOLEObject) 

EOleException exception class with the message 'View.PasteSpecial: invalid request. The specified data type is not available'

I use the slide sorter view, copying and pasting work fine, I'm just trying to add the "keep original formatting" command.

Thanks in advance

+4
source share
1 answer

I think I found a solution:

This code in Delphi (doesn't work)

 var OrigSlide, NewSlide : Variant; NewSlide.Design := OrigSlide.Design; 

on the right hand side, Delphi seems to accept only variant_variable, it does not accept variant_variable.property

The left side seems to work the opposite way?!?

When I replaced it with this code, it works

 OrigSlide := OrigSlide.Design; NewSlide.Design := OrigSlide; 

But I can only guess why.

+1
source

Source: https://habr.com/ru/post/1394774/


All Articles