Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 688

Cannot make ShellExecute work!

$
0
0
Hi All,

I've been fighting this all weekend. I made a small HTA app that pulls up all GIF files from the folder it's run from and displays them in a 3 column table. Once that was done, I decided I wanted it to open whichever GIF with it's default program when clicked. No matter what syntax I use, it gives me a path error msg. The only way it will work is to hard-code the file's path (which is obviously not gonna work, except for testing). There is a loop before this step that reads the filenames and adds them to the cells (76 files at present).


Code:

    Function RunProgram
        mFile = document.activeElement.innerText
        mFile = fldr.Path & "\" & mfile
        MsgBox mFile
        Set objShell = CreateObject("Shell.Application")
        objShell.ShellExecute "C:\Users\Russ\Pictures\Avatars\atom.gif"
        ' or
        objShell.ShellExecute mFile
        set objShell = nothing
    End Function



Code:

mFile = fldr.Path & "\" & mfile_______________          ___shows: C:\Users\Russ\Pictures\Avatars\atom.gif
mFile = """" & fldr.Path & "\" & mfile & """"______________shows: "C:\Users\Russ\Pictures\Avatars\atom.gif"
The Msgbox verifies what the above line(s) show.

With the hard-coded path, it works fine, but using either mFile variable (which appears exactly the same depending on the quotes) causes "Windows cannot find 'C:\Users\Russ\Pictures\Avatars\atom.gif'. Make sure you typed the name correctly and try again". I even tried adding the path to my GIF program (Image Eye.exe) as an arguement and got the same "path error" even though it comes from within Image Eye now.

This is a Win7 machine with Image Eye as the default GIF "open" program...

I'm pulling my hair!

Russ

Viewing all articles
Browse latest Browse all 688

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>