Shell Command only Works Sometimes. HELP!

I've written an image viewing application in VB6 Pro.  A user views images stored on his/her computer in an image box and can do various things like editing.  Basically, the user configures my program to work with their favorite graphics editor.  I save this info to the registry without a problem.  Anyway, there's a huge bug in my edit routine.  I found it today when I installed my program on someone else's computer.  And MS Paint was the problematic editor, even for BMP files.

Here's the code I use to bring the image up in the selected editor:

Private Sub mnuFileEdit_Click()
    Dim dblRetVal As Double
    Dim strReply As String
    If m_EditorChoice = "" Then
        strReply = MsgBox("You must choose a graphic editing " _
                & "program on your system to edit " _
                & vbCrLf & "images that you view." _
                & vbCrLf & vbCrLf _
                & "Click Preferences ---> Graphics Editor on " _
                & "the Lucid P.i.X. menu to " _
                & vbCrLf & "make your selection.", _
                vbOKOnly, "Graphic Editor Not Chosen")
        Exit Sub
    End If
    If m_SelectedFile = "" Then
        strReply = MsgBox("You must select a file in the file list box" _
                & vbCrLf & " before you can edit.", _
                "File not selected for edit")
        Exit Sub
        dblRetVal = Shell(m_EditorChoice & " " & m_SelectedFile, 1)
    End If
End Sub

SelectedFile is the pathname and filename of the file to edit.  My editors (PhotoPaint, Debabelizer, etc.) work fine, but others (like Paint and NetStudio) will not recognize the path and filenames that have spaces in them.  For instance a file, Dog.bmp in the My Documents folder will produce an annoying error like "My.bmp not found."  This only happens with some editors, so I'm at a loss as to how to work this out.  These same editors will open these files on their own, just not from my program.  I'd be grateful for any ideas.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Convert the long names into short path names using GetShortPathName API:

Private Declare Function GetShortPathName Lib "kernel32" _
         Alias "GetShortPathNameA" (ByVal lpszLongPath As String, _
         ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
Private Function GetShortName(ByVal sLongFileName As String) As String
    Dim lRetVal As Long
    Dim sShortPathName As String
    Dim iLen As Integer
    'Set up buffer area for API function call return
    sShortPathName = Space(255)
    iLen = Len(sShortPathName)
    'Call the function
    lRetVal = GetShortPathName(sLongFileName, sShortPathName, iLen)
    'Strip away unwanted characters.
    GetShortName = Left(sShortPathName, lRetVal)
End Function

Private Sub Command1_Click()
Debug.Print GetShortName(App.Path)
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ljklinskyAuthor Commented:
Bless you! :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.