0
(Excel和PowerPoint中2011適用於Mac)Excel的VBA調用宏的PowerPoint演示失敗精細
我有打開PowerPoint和執行宏Excel宏。 如果我執行宏的PowerPoint演示直接它工作正常,但如果我從Excel宏調用執行它,它失敗,運行時錯誤「68」:設備不可用
正是這種循環之前:
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
所以你的路徑變量被設置爲「:tmp:」。無論在哪種情況下,我都看不出它是如何工作的。不應該是本地驅動器參考,例如「C:\ tmp \」或網絡位置,如「\\ myServer \ tmp \」。根據MSDN,Dir函數將PathName參數作爲「指定文件名,目錄或文件夾名稱或驅動器卷標的字符串表達式」。 –
Hello JamieG,謝謝你的回答。 :tmp只是對演示文稿所在的實際文件夾中tmp文件夾的引用。我會嘗試將其改爲全球,看看這是否可能是根本原因。謝謝! – Diego
解決了這個問題。當您直接在Powerpoint上執行宏時,相對路徑「:tmp:」正常工作。如果你想從excel中調用powerpoint宏,你必須把全局路由(activepresentation.path $「:tmp:」 – Diego