ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Shell function problem (MS Access) (https://www.excelbanter.com/excel-programming/390920-shell-function-problem-ms-access.html)

mabond

Shell function problem (MS Access)
 
Hi

Trying to do this within Excel VBA but having a problem with the following
shell command. The command line switch can't open the named file.

Dim retVal
retVal = Shell("C:\Program Files\Microsoft Office\Office\MSACCESS.EXE S:\My
Folder\MyFile.mdb", 1)

The problem stems, I assume, from the space in the pathname (something over
which I have no control)

Is there a known solution to this issue or is there a more correct way to
type the pathname and filename to overcome the problem. i've tried several
combinations of parentheses with no luck

Any help appreciated

Michael Bond


Rick Rothstein \(MVP - VB\)

Shell function problem (MS Access)
 
Trying to do this within Excel VBA but having a problem with the following
shell command. The command line switch can't open the named file.

Dim retVal
retVal = Shell("C:\Program Files\Microsoft Office\Office\MSACCESS.EXE
S:\My
Folder\MyFile.mdb", 1)

The problem stems, I assume, from the space in the pathname (something
over
which I have no control)


Give this a try...

retVal = Shell("""C:\Program Files\Microsoft Office\Office\MSACCESS.EXE""
""S:\My Folder\MyFile.mdb""", 1)

Rick


Vergel Adriano

Shell function problem (MS Access)
 
Michael,

Try enclosing the path and filename with double quotes. like this:

retVal = Shell("C:\Program Files\Microsoft Office\Office\MSACCESS.EXE
""S:\My Folder\MyFile.mdb""", 1)


--
Hope that helps.

Vergel Adriano


"mabond" wrote:

Hi

Trying to do this within Excel VBA but having a problem with the following
shell command. The command line switch can't open the named file.

Dim retVal
retVal = Shell("C:\Program Files\Microsoft Office\Office\MSACCESS.EXE S:\My
Folder\MyFile.mdb", 1)

The problem stems, I assume, from the space in the pathname (something over
which I have no control)

Is there a known solution to this issue or is there a more correct way to
type the pathname and filename to overcome the problem. i've tried several
combinations of parentheses with no luck

Any help appreciated

Michael Bond


Helmut Weber[_2_]

Shell function problem (MS Access)
 
Hi Michael,

strTmp = "C:\Program Files\Microsoft Office\Office\"
strtmp = strtmp & "MSACCESS.EXE S:\My Folder\MyFile.mdb"
strtmp = chr(34) & strtmp & chr(34)

retVal = Shell(strtmp, 1)

--

Helmut Weber

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

mabond

Shell function problem (MS Access)
 
Rick

thanks, worked a treat...that was one combination I didn't try! Appreciate
the help and spead of response.

Regards

Michael Bond

"Rick Rothstein (MVP - VB)" wrote:

Trying to do this within Excel VBA but having a problem with the following
shell command. The command line switch can't open the named file.

Dim retVal
retVal = Shell("C:\Program Files\Microsoft Office\Office\MSACCESS.EXE
S:\My
Folder\MyFile.mdb", 1)

The problem stems, I assume, from the space in the pathname (something
over
which I have no control)


Give this a try...

retVal = Shell("""C:\Program Files\Microsoft Office\Office\MSACCESS.EXE""
""S:\My Folder\MyFile.mdb""", 1)

Rick



mabond

Shell function problem (MS Access)
 
Thanks Vergel

Appreciate the help. Got it working now.

Regards

Michael Bond

"Vergel Adriano" wrote:

Michael,

Try enclosing the path and filename with double quotes. like this:

retVal = Shell("C:\Program Files\Microsoft Office\Office\MSACCESS.EXE
""S:\My Folder\MyFile.mdb""", 1)


--
Hope that helps.

Vergel Adriano


"mabond" wrote:

Hi

Trying to do this within Excel VBA but having a problem with the following
shell command. The command line switch can't open the named file.

Dim retVal
retVal = Shell("C:\Program Files\Microsoft Office\Office\MSACCESS.EXE S:\My
Folder\MyFile.mdb", 1)

The problem stems, I assume, from the space in the pathname (something over
which I have no control)

Is there a known solution to this issue or is there a more correct way to
type the pathname and filename to overcome the problem. i've tried several
combinations of parentheses with no luck

Any help appreciated

Michael Bond


mabond

Shell function problem (MS Access)
 
Helmut

Thanks

Michael

"Helmut Weber" wrote:

Hi Michael,

strTmp = "C:\Program Files\Microsoft Office\Office\"
strtmp = strtmp & "MSACCESS.EXE S:\My Folder\MyFile.mdb"
strtmp = chr(34) & strtmp & chr(34)

retVal = Shell(strtmp, 1)

--

Helmut Weber

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"



All times are GMT +1. The time now is 05:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com