vba is letting me down

  • Onderwerp starter Onderwerp starter dm89
  • Startdatum Startdatum
Status
Niet open voor verdere reacties.

dm89

Gebruiker
Lid geworden
20 sep 2006
Berichten
7
Private Declare Function sndPlaySound Lib "winmm.dll" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Public Function PlaySound(Pfad As String)
sndPlaySound Pfad, 0
End Function




Private Sub UserForm_Click()

End Sub

Private Sub UserForm_Initialize()
ComboBox1.AddItem ("p")
Call PlaySound("F:\Prodigy - Smack My Bitch Up.mp3")
End Sub

Ik heb dit gedaan en nu krijg ik de melding: Fout 453 tijdens uitvoering
Kan ingangspunt van DLL sndPlaySound in winmm.dll niet vinden


Weet iemand wat er misgaat?

VBA-er in nood :confused:
 
vond dit stukje code op Internet:

using System.Runtime.InteropServices;

[DllImport("winmm.dll", EntryPoint="sndPlaySoundA")]
static extern int sndPlaySound(string lpszName, int dwFlags);

sndPlaySound("filename.wav", 1);

Had blijkbaar met VB.NET te maken, maar enkele dingen kun je er wel uit afleiden (een paar mogelijkheden):

1. De declaratie
Private Declare Function sndPlaySound Lib "winmm.dll" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
deugt misschien niet.
Probeer de volgende:
Private Declare Function sndPlaySoundA Lib "winmm.dll" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Dit lijkt me het meest waarschijnlijk, en in overeenstemming met de foutmelding.

2. De declaratie klopt misschien niet wat betreft de 2de parameter, die je Long maakt, terwijl de voorbeeldcode uitgaat van Integer. Aangepast:
Private Declare Function sndPlaySound Lib "winmm.dll" (ByVal lpszSoundName As String, ByVal uFlags As Integer) As Long

danwel
Private Declare Function sndPlaySoundA Lib "winmm.dll" (ByVal lpszSoundName As String, ByVal uFlags As Integer) As Long

Dit is beduidend minder kansrijk dan 1.

3. De dubbele aanhalingstekens in je parameter ("F:\Prodigy - Smack My Bitch Up.mp3") zullen misschien letterlijk doorgegeven moeten worden, inclusief de "-tekens zelf.

Geen idee hoe je dat doet, maar jij weet dat wel, waarschijnlijk.

Misschien via ("""F:\Prodigy - Smack My Bitch Up.mp3""") danwel (""F:\Prodigy - Smack My Bitch Up.mp3"")?
Overigens lijkt dit in zijn geheel niet met je melding te maken te hebben, dit is dus absoluut het minst kansrijk! :)


We horen wel of iets hiervan je geholpen heeft.

Tijs.
 
Laatst bewerkt:
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan