我创建了以下宏来打开某个地图中的所有ppt文件
Sub openAllPPT()
Dim strCurrentFile As String
Dim strFileSpec As String
strFileSpec = "C:\Documents and Settings\aa471714\Desktop\Nieuwe map*.ppt"
strCurrentFile = Dir$(strFileSpec)
While Len(strCurrentFile) > 0
Presentations.Open (strCurrentFile)
strCurrentFile = Dir$
Wend
End Sub
当我运行它时,我确实看到了任何打开的东西。有人知道我错过了什么吗?
答案 0 :(得分:2)
Dir只返回文件名,而不是文件的完整路径。 试试这个:
Sub openAllPPT()
Dim strCurrentFile As String
Dim strFileSpec As String
Dim strDirectory As String
strDirectory = "C:\Documents and Settings\aa471714\Desktop\"
strFileSpec = "Nieuwe map*.ppt"
strCurrentFile = Dir$(strDirectory & strFileSpec)
While Len(strCurrentFile) > 0
'Presentations.Open (strDirectory & strCurrentFile)
Debug.Print strDirectory & strCurrentFile
strCurrentFile = Dir$
Wend
End Sub