VBA Powerpoint. How can i set environment current directory?
I also tried this code:
Sub test()
Dim sPath As String
sPath = ActiveWorkbook.Path
MsgBox sPath
End Sub
But is says: Object required
Please help me to make it work ...
Here's how you can find macros and VBA modules in your document: In Word or Excel, click View > Macro > View Macros. In PowerPoint, click View > Macro.
Tim has provided the answer. The file path of the active presentation is stored in the property, ActivePresentation.Path. If the presentation file has not been saved yet this property will contain an empty string. To test this out 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
Note that this is a read-only property. You can't set this variable.
https://docs.microsoft.com/en-us/office/vba/api/powerpoint.presentation.path
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With