vb.net - Run PowerPoint with the exe macro file
问题描述
My development environment is Windows 8 64Bit & 10 64Bit, and Visual Studio is 2013.
The VBA file I wrote looks like this:
// source start !!!
Imports PowerPoint = Microsoft.Office.Interop.PowerPoint
Module Module1
Sub Main(ByVal path() As String)
Dim oApplication As PowerPoint.Application = Nothing
Dim oPressentation As PowerPoint.Presentation = Nothing
Try
oApplication = New Microsoft.Office.Interop.PowerPoint.Application()
oPressentation = oApplication.Presentations.Add
Dim macroPath As String = path(0)
Dim savePath As String = path(1)
oPressentation.VBProject.VBComponents.Import(macroPath)
oApplication.Run("ExportPowerPoint")
oPressentation.SaveAs(savePath)
Catch ex As Exception
Finally
If Not oPressentation Is Nothing Then
oPressentation = Nothing
End If
If Not oApplication Is Nothing Then
oApplication = Nothing
End If
GC.Collect()
GC.WaitForPendingFinalizers()
End Try
End Sub
End Module
// source end !!!
When the function is executed, it executes the power point and executes the macro.
However, if the power point is executed before executing the function, the function does not work properly when the exe file is executed. The same power point just turns on and ends.
In addition, after executing the function, even if you run the power point on the desktop.
解决方案
推荐阅读
- java - 如何允许用户在 Android 和 Firebase 实时数据库规则中更新另一个用户的相关数据?
- automated-tests - 如何在无头 chrome [机器人框架] 中下载文件
- javascript - 如何使用 Selenium Java 单击应在同一窗口中打开的链接
- c# - 列表具有来自不同类别的单独条目
- python - .split() 不会拆分一行中的所有单词
- python - 将元组清理为字符串
- python - 将字典元素而不是整个字典传递给Python中的函数?
- google-cloud-platform - 如何在 GCP 中打开端口
- javascript - 为 Jira 故事创建/更新子任务
- python - PyBind11:返回 c++ 数组作为 numpy 数组更改值