【发布时间】:2015-04-17 05:06:56
【问题描述】:
我目前正在尝试自动化一种方法,将 powerpoint 幻灯片转换为我可以在我的应用程序中使用的图像。我使用 powerpoint 插件关闭了该方法:
Private Function convert_slide(ByVal targetfile As String, ByVal imagepath As String, ByVal slide_index As Integer)
Dim pptapplication As New Microsoft.Office.Interop.PowerPoint.Application
Dim prsPres As Microsoft.Office.Interop.PowerPoint.Presentation = pptapplication.Presentations.Open(targetFile, True, False, False)
prsPres.Slides(slide_index).Export(imagepath, "jpg", 0, 0)
prsPres.Close()
pptapplication.Quit()
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(prsPres)
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(pptapplication)
Return Image.FromFile(imagepath)
End Function
现在这适用于一个文件,但如果我再次尝试运行该函数,它会说目标路径正在使用中。似乎电源点正在锁定文件。我不想每次运行时都更改文件名。我想每次都重用那个临时文件。任何想法如何使它不会被锁定?
【问题讨论】:
标签: vb.net powerpoint