RawlinsCross
Active Member
- Joined
- Sep 9, 2016
- Messages
- 437
So I have a question on the use of Environ function in VBA. If I want to open a file from my desktop, it appears I need to use forward slashes instead of backslashes? Is this correct? Is there a forward slash version on Environ?
Code:
Private Sub PortConvey_Click()
Dim sPath As String
'MTS files are video files from a Sony digital camera
sPath = Environ("USERPROFILE") & "\Desktop\TrainingVideos\ConConvey.MTS"
Debug.Print sPath 'Debug.Print prints out C:\Users\jhalfyard\Desktop\TrainingVideos\ConConvey.MTS
'This does not play the video but throws no error
Shell "C:\Program Files\Windows Media Player\wmplayer.exe sPath"
'This does play the video
Shell "C:\Program Files\Windows Media Player\wmplayer.exe c:/Users/jhalfyard/Desktop/TrainingVideos/ConConvey.MTS"
End Sub
Last edited: