Excel-VBA 调用 Powerpoint 宏失败,而 运行 它直接在 PowerPoint 上工作正常

Excel-VBA calling a Powerpoint Macro fails while running it directly on PowerPoint works fine

(Excel 和 PowerPoint 2011 for Mac)

我有一个 excel 宏,可以打开 powerpoint 并执行宏。 如果我直接执行 powerpoint 宏,它工作正常,但如果我从 excel 宏调用执行它,它会失败并显示 运行-time error '68': Device unavailable

在这个循环之前:

Dim strfilee As String


mydir = ":tmp"
strpath = mydir & ":"
strfilee = Dir(strpath)  <--- Failing on this line


''''Loop through each file in the folder to find the one with the OS parameters

    i = 0

    Do While Len(strfilee) > 0
    cellplace = "A" & i

        If Right(strfilee, 11) = "params.pptx" Then
        lspace = InStr(1, strfilee, "_", vbTextCompare)
        target_name = Trim(Left(strfilee, lspace - 1))
        sc_file_name = "tmp" & ":" & strfilee

                With ActivePresentation
                    number_slides = .Slides(.Slides.Count).SlideNumber
                  End With
                ActivePresentation.Slides.InsertFromFile sc_file_name, number_slides


         End If
        strfilee = Dir
      i = i + 1

    Loop

使用 Dir 函数时尝试使用完全限定路径。