嵌入的 OLEO 对象在编辑时覆盖自身

问题描述

我目前正在尝试执行以下步骤:

  1. 将 PowerPoint 模板嵌入到 Excel 中
  2. 运行一个完成的宏来编辑 PP 模板
  3. 将新编辑的 PP 保存为新的 PP 文件
  4. 如果需要,可以重复第 1-3 步

为此,我将 PP-Template 作为 OLEO-Object(通过 Insert-->Object-->Choose PPTX)嵌入到名为“PP Export”的工作表上,名为“PPtemplate”并运行以下代码

'Dim oEmbFile As Object
'Application.displayAlerts = False
'Set oEmbFile = ThisWorkbook.Sheets("PP Export").OLEObjects("PPtemplate")
'oEmbFile.Verb Verb:=xlOpen
'Set oEmbFile = nothing
'Set PPpres = PPapp.ActivePresentation
'Application.displayAlerts = True

这很好用,但我只能这样做一次。这是因为一旦第一个宏编辑模板,它会自动保存这些更改,模板不再是模板而是第一次宏运行(编辑模板)的结果...

我怎样才能阻止它覆盖自己?也许以某种方式将模板提取用户 PC 然后打开并编辑它,因此即使在运行宏之后嵌入的模板也始终相同?

任何帮助/提示将不胜感激! 感谢并保持健康

编辑 - 解决方案:

  1. 要求保存位置
  2. 保存嵌入的副本
  3. 打开副本以编辑副本而不是嵌入文件
With Application.FileDialog(msoFileDialogFolderPicker)
   .AllowMultiSelect = False
    .Show
     PPdateipfad = .SelectedItems.Item(1)
End With

Dim oEmbFile As Object
Application.displayAlerts = False
Set oEmbFile = ThisWorkbook.Sheets("PP Export").OLEObjects("PPvorlage")
oEmbFile.Verb Verb:=xlOpen
Set oEmbFile = nothing
Set PPpres = PPapp.ActivePresentation
Application.displayAlerts = True
PPpres.SaveAs (PPdateipfad + "\QM-Check Präsentation.pptx")
PPpres.Close
Set PPpres = PPapp.Presentations.Open(PPdateipfad + "\QM-Check Präsentation.pptx")

解决方法

解决方案:

  1. 要求保存位置
  2. 保存嵌入的副本
  3. 打开副本以编辑副本而不是嵌入文件
With Application.FileDialog(msoFileDialogFolderPicker)
   .AllowMultiSelect = False
    .Show
     PPdateipfad = .SelectedItems.Item(1)
End With

Dim oEmbFile As Object
Application.DisplayAlerts = False
Set oEmbFile = ThisWorkbook.Sheets("PP Export").OLEObjects("PPvorlage")
oEmbFile.Verb Verb:=xlOpen
Set oEmbFile = Nothing
Set PPpres = PPapp.ActivePresentation
Application.DisplayAlerts = True
PPpres.SaveAs (PPdateipfad + "\QM-Check Präsentation.pptx")
PPpres.Close
Set PPpres = PPapp.Presentations.Open(PPdateipfad + "\QM-Check Präsentation.pptx")