Shell Command only Works Sometimes. HELP!
Posted on 1999-11-09
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")
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")
dblRetVal = Shell(m_EditorChoice & " " & m_SelectedFile, 1)
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.