将 PowerPoint VBA 代码转换为 Delphi,“保留源格式”问题
我正在使用 Delphi(2010),但我是 PowerPoint(2010) 的新手,
我发现了两个用于使用“保留源格式”复制幻灯片的代码:
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
它们都在 PowerPoint 中给出了所需的结果,但在 Delphi 中我得到了例外:
test1,
new_slide.Design = orig_slide.Design
异常类 EOleSysError 行,带有消息“未找到成员”
test2,
ActiveWindow.View.PasteSpecial (DataType = ppPasteOLEObject)
异常类 EOleException 行,带有消息“View.PasteSpecial:无效请求”。指定的数据类型不可用'
我正在使用幻灯片排序视图,复制和粘贴工作正常,我只是尝试添加“保留源格式”命令。
提前致谢
I am working with Delphi(2010), but I'm new with PowerPoint(2010)
I've found two codes for copying slides with "keep source 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
They both are giving desired results in PowerPoint but in Delphi i get exceptions :
test1, line
new_slide.Design = orig_slide.Design
exception class EOleSysError with message 'Member not found'
test2, line
ActiveWindow.View.PasteSpecial (DataType = ppPasteOLEObject)
exception class EOleException with message 'View.PasteSpecial : Invalid request. The specified data type is unavailable'
I am using Slide Sorter View, copying and pasting are working ok, I'm only trying to add "keep source formatting" command.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我找到了一个解决方案:
Delphi中的这段代码(不起作用)
在右侧,Delphi似乎只接受variable_variable,它不接受variable_variable.property
左侧似乎以相反的方式工作?!?
当我用这段代码替换它时,它可以工作
但我只能猜测为什么。
I think I've found a solution :
This code in Delphi (doesn't work)
on the right side, Delphi seems to accept only variant_variable, it doesn't accept variant_variable.property
Left side seems to work in opposite way ?!?
When I replaced it with this code, it works
But I can only guess why.