7

VBA 简报。如何设置环境当前目录?

我也试过这段代码:

Sub test()
Dim sPath As String
sPath = ActiveWorkbook.Path
MsgBox sPath
End Sub

但是是说:Object required

请帮我使它工作...

4

1 回答 1

13

蒂姆已经给出了答案。你可以使用类似的东西:

Sub test()
    Dim sPath As String
    sPath = ActivePresentation.Path
    If Len(sPath) > 0 Then
        MsgBox ActivePresentation.Name & vbNewLine & "saved under" & vbNewLine & sPath
    Else
        MsgBox "File not saved"
    End If
End Sub
于 2012-09-23T07:26:22.140 回答