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 ...
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://learn.microsoft.com/en-us/office/vba/api/powerpoint.presentation.path