VBA 幻灯片。如何获取文件的当前目录路径到 VBA 中的字符串?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12546181/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 14:03:44  来源:igfitidea点击:

VBA Powerpoint. How to get file's current directory path to a string in VBA?

vbapowerpointpowerpoint-vba

提问by Andrei20193

VBA Powerpoint. How can i set environment current directory?

VBA 幻灯片。如何设置环境当前目录?

I also tried this code:

我也试过这个代码:

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

But is says: Object required

但是是说: Object required

Please help me to make it work ...

请帮我让它工作......

回答by brettdj

Tim has provided the answer. You could use something like:

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

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