0

我正在做一个项目,将两个或多个 pp 演示文稿加入一个新的演示文稿中。原始 pp 演示文稿的选择位于基于 Web 的 Lotus Notes xPage 中,提交后,Lotusscript 与 OLE Powerpoint 对象对话。以正确的顺序将幻灯片添加到新的演示文稿中是没有问题的。问题是在添加与幻灯片模板的原始连接后丢失了。

为了解决这个问题,我找到了下一个代码片段:

Sub joiner()
 Dim sFileName As String
 Dim oDonor As Variant
 Dim otarget As Variant
 Dim i As Integer
 On Error GoTo errhandler

 Set otarget = ActivePresentation

 Do While sFileName <> ""
 Set oDonor = Presentations.Open(Environ("USERPROFILE") & "\Desktop\joiner\" &     sFileName, msoFalse)

 For i = 1 To oDonor.Slides.Count
 oDonor.Slides(i).Copy

 With otarget.Slides.Paste(otarget.Slides.Count + 1)
 .Design = oDonor.Slides(i).Design
 .ColorScheme = oDonor.Slides(i).ColorScheme
 End With

 Next i

 oDonor.Close
 Set oDonor = Nothing
 sFileName = Dir()
 Loop

 End Sub

我必须将演示文稿 oDonor 和 oTarget 声明为 Variant,因为 lotusscript 不理解Dim oTarget As Presentation

这可能是代码在以下位置返回类型不匹配错误的原因: .Design = oDonor.Slides(i).Design

我的问题是:

  1. 我是以正确的方式加入还是有更好的解决方案?
  2. 有没有解决类型不匹配错误的方法?

*ps:结果展示不一定是可编辑的,所以可能不需要添加模板。

2012 年 4 月 10 日更新:下一个代码解决了模板问题。现在仍然缺少的是某些幻灯片使用的背景图像。请参阅:https ://stackoverflow.com/questions/12731691/how-to-export-a-backgroundimage-of-a-slide-to-the-filesystem

Dim oDonor As Variant
Dim h As Integer
Dim thetmplt As Variant
Dim thetmpltname As String
Dim thetmpltnew As Variant
Dim thetmpltnamenew As String

Set oDonor = PPApplication.Presentations.Open(tempdirectory +
jobid+CStr(filenamearray  (i)),False,False,False)

thetmplt = oDonor.TemplateName  
Call oDonor.SaveAs(tempdirectory +jobid+CStr(i)+ thetmplt+".pot" ,5, -1)

For h = 1 To oDonor.Slides.Count

Dim oTargetSlide As Variant         

oDonor.Slides(h).Copy
Set oTargetSlide =  newPres.Slides.Paste()


Next        

Dim theubound As Variant
theubound = oDonor.Slides.Count
ReDim thearray(1 To k + theubound) As Variant


For k = k To k + oDonor.Slides.Count-1

thearray(k) = k
Next

Call newPres.Slides.Range(thearray()).ApplyTemplate(tempdirectory +
jobid+CStr(i+thetmplt+".pot")

oDonor.Close
Set oDonor = Nothing
4

1 回答 1

0

这只是一种预感,但请尝试:

Dim oTargetSlide as Variant
Set oTargetSlide =  otarget.Slides.Paste(otarget.Slides.Count + 1)(1)
With oTargetSlide
 .Design = oDonor.Slides(i).Design
 .ColorScheme = oDonor.Slides(i).ColorScheme
 End With
于 2012-10-01T14:03:42.287 回答