MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Using Shell with an associated file type?

  Asked By: Can    Date: Oct 13    Category: MS Office    Views: 928

I have researched and tried a bunch of flavored variations
from http://www.mvps.org/dmcritchie/excel/shell.htm

But no joy.

The following VBA line works but requires me to embed my associated file
in a batch file first. What I would like is to "run" or "start" the .vmx
file directly as can be done from the Run command or within Explorer.

RetVal = Shell("c:\vmfg.bat", vbMinimizedNoFocus)

Contents of vmfg.bat:


According to the Website something like this should work but I get a
"file not Found" error

Shell "start c:\Vmfg.vmx"



10 Answers Found

Answer #1    Answered By: Yvette Griffin     Answered On: Oct 13

Try leaving the "Start" out.

Get back to us if it doesn't work.

Answer #2    Answered By: Brent Brown     Answered On: Oct 13

unfortunately, removing the "Start" does not work  but as I understand
it Shell requires an executable (.EXE, CMD, BAT, .COM).

I might have to accept the clunky workaround and build both text
files. YUCK!

open to another suggestion...

Answer #3    Answered By: Arnelle Schmidt     Answered On: Oct 13

As I read the page at the link I sent, shell  *doesn't* look for the items in
the environment variable "pathtext" if there is an extension on the first
token of the command line  and command  extensions are enabled.

There is also documentation on the CMD command at

Does the file  run if you open a command window manually and type  the program

Answer #4    Answered By: Cleopatra Massri     Answered On: Oct 13

the .VMX associated file  will auto launch the windows
file from a Dos Command line.

example may help but the application (.exe) I am
running does NOT accept parameters directly - hence the need for the
launching from the associated file.

Answer #5    Answered By: Muntasir Bashara     Answered On: Oct 13

any working examples using VBA's shell
command with associated filetype?

Answer #6    Answered By: Cadencia Bernard     Answered On: Oct 13

And perhaps check out the syntax of the start  command....


Answer #7    Answered By: Patty Freeman     Answered On: Oct 13

I'm not familiar with the application.
Does it accept a filename on the command-line?
Perhaps you can use something like:

("C:\msoffice\excel.exe """ & fullpathandfilename & """")

gotta watch the embedded quotes...

I know I've done something like that, but it's at work.

Answer #8    Answered By: Johnathan Nelson     Answered On: Oct 13

What about

Dim myShell As Object
Set myShell = CreateObject("WScript.Shell")
myShell.Run "c:\Vmfg.vmx"


Answer #9    Answered By: Horia Ahmed     Answered On: Oct 13

Thanks, but I can't take credit for it. Here's the original:


Answer #10    Answered By: Sophie Williamson     Answered On: Oct 13

Perhaps but you "Beat" Google... (granted, I limited my search with
"Excel VBA".)

Didn't find what you were looking for? Find more on Using Shell with an associated file type? Or get search suggestion and latest updates.