referring to current folder

bruno2k_ad34

New Member
Joined
Oct 27, 2018
Messages
3
hi,
can you please help me to understand this issue and correct it?
i´ve addapted code to play sounds and it works fine if the mp3 file is placed at
C:\Users\Bruno Andrade\Music\


Sub M_02SomNiv2()
Dim play As String
play = """C:\Users\Bruno Andrade\Music\som02-Niv2.mp3"""
Shell "C:\Program Files\Windows Media Player\wmplayer /play " & play, False
End Sub


however, if i want to place the files at the current folder (the same as open excel), it doesn´t play any sound.


Sub M_01SomNiv2()
Dim play As String
play = ThisWorkbook.Path & "\som02-Niv2.mp3"'only this line changed
Shell "C:\Program Files\Windows Media Player\wmplayer /play " & play, False
End Sub


what´s wrong? please help me.
thanks
Bruno
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Looks like quotation marks are needed. This worked for me

Code:
[COLOR=#333333]Sub M_01SomNiv2()[/COLOR]
[COLOR=#333333]Dim play As String[/COLOR]
play = """" & ThisWorkbook.Path & "[COLOR=#333333]\som02-Niv2.mp3[/COLOR]" & """"
[COLOR=#333333]Shell "C:\Program Files\Windows Media Player\wmplayer /play " & play, False[/COLOR]
[COLOR=#333333]End Sub
[/COLOR]
 
Upvote 0
Looks like quotation marks are needed. This worked for me

Code:
[COLOR=#333333]Sub M_01SomNiv2()[/COLOR]
[COLOR=#333333]Dim play As String[/COLOR]
play = """" & ThisWorkbook.Path & "[COLOR=#333333]\som02-Niv2.mp3[/COLOR]" & """"
[COLOR=#333333]Shell "C:\Program Files\Windows Media Player\wmplayer /play " & play, False[/COLOR]
[COLOR=#333333]End Sub
[/COLOR]

Hi,
that´s it. it works fine. thank you very much.
in this case, why do i have to use 3 quotations marks?
how do i score your answer??
best regards and thanks a lot
Bruno
 
Upvote 0
The 4 are to put 2 quotation marks in. so "A" is A and """" is ""

No scores here, glad it helped!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top