Excel VBA 创建 MS 项目时出错

Excel VBA error when creating MS Project

当我在 excel 中创建一个 "MS Project" 对象时,我尝试使用此代码检查对象是否已创建:

Dim pjapp As Object

Set pjapp = CreateObject("MSProject.Application")

If pjapp Is Nothing Then
    MsgBox "Project is not installed"
End If

我不断得到:

"运行-时间错误'429': ActivX 组件无法创建对象

虽然我有一个代码可以处理这类问题。

我搜索了解决方案,但没有找到。 感谢您的帮助。

您没有任何代码来处理该错误(至少您发布的代码没有)。一种方式是:

Dim pjapp As Object
On Error Resume Next
Set pjapp = CreateObject("MSProject.Application")
On Error Goto 0

If pjapp Is Nothing Then
    MsgBox "Project is not installed"
End If