Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Access Form question

Access Form question

Scheduled Pinned Locked Moved Visual Basic
helplinuxquestioncareer
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aldrus
    wrote on last edited by
    #1

    I've a problem when using a command control in a form who is linked to a code that opens a executable program (Windows Media Player) and a Mp3's file. The Mp3's file is located in a folder that has spaces on it. The problem is the file doesn't open and the WMPlayer sends a message (file extension not recognized). I know that the problem is in the spaces in the folder. Tanks a lot. Here is the code: Private Sub cmdPlay_Click() On Error GoTo Err_cmdPlay_Click Dim stAppName As String Dim PlayFullName As String PlayFullName = "G:\MP3\045- Mp3\test.mp3" stAppName = "D:\Program Files\Windows Media Player\wmplayer.exe " & PlayFullName Call Shell(stAppName, vbMinimizedFocus) Exit_cmdPlay_Click: Exit Sub Err_cmdPlay_Click: MsgBox Err.Description Resume Exit_cmdPlay_Click End Sub

    D 1 Reply Last reply
    0
    • A aldrus

      I've a problem when using a command control in a form who is linked to a code that opens a executable program (Windows Media Player) and a Mp3's file. The Mp3's file is located in a folder that has spaces on it. The problem is the file doesn't open and the WMPlayer sends a message (file extension not recognized). I know that the problem is in the spaces in the folder. Tanks a lot. Here is the code: Private Sub cmdPlay_Click() On Error GoTo Err_cmdPlay_Click Dim stAppName As String Dim PlayFullName As String PlayFullName = "G:\MP3\045- Mp3\test.mp3" stAppName = "D:\Program Files\Windows Media Player\wmplayer.exe " & PlayFullName Call Shell(stAppName, vbMinimizedFocus) Exit_cmdPlay_Click: Exit Sub Err_cmdPlay_Click: MsgBox Err.Description Resume Exit_cmdPlay_Click End Sub

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      The problem is the spaces, your right. But solution is also pretty easy. The problem comes because the spaces are seen as command-line argument seperators. This is the command-line your sending to Shell:

      D:\...\wmplayer.exe g:\mp3\045- mp3\test.mp3

      Your actually telling wmplayer that there are 2 command-line parameters:

      'g:\mp3\045-' and 'mp3\test.mp3'

      The solution is to put quotes around both parts of the command-line:

      PlayFullName = chr$(34) & "G:\MP3\045- Mp3\test.mp3" & chr$(34)
      stAppName = chr$(34) & "D:\Program Files\Windows Media Player\wmplayer.exe" & chr$(34) & " " & PlayFullName

      Now your sending the command-line as:

      "D:\...\wmplayer.exe" "G:\mp3\045- mp3\test.mp3"

      The quotes will prevent the spaces from becoming argument seperators. RageInTheMachine9532

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups