Need syntax mod for this command...

  • Thread starter rfuscjr via AccessMonster.com
  • Start date
R

rfuscjr via AccessMonster.com

Dim RetVal
RetVal = Shell("EXCEL X:\LVPG\Reports\HBI Resources\
LVPG_AR_AtbSelfpayFinalRegAcctBal.xls", 1)


It should open a file called:

X:\LVPG\Reports\HBI Resources\LVPG_AR_AtbSelfpayFinalRegAcctBal.xls

It errors out because there is a space in the path to the file (HBI Resources)
.. I can not change the folder name. How do I modify this code so that
MsAccess recognizes it.

THANKS!
 
S

Stefan Hoffmann

hi,
RetVal = Shell("EXCEL X:\LVPG\Reports\HBI Resources\
LVPG_AR_AtbSelfpayFinalRegAcctBal.xls", 1)
It should open a file called:
X:\LVPG\Reports\HBI Resources\LVPG_AR_AtbSelfpayFinalRegAcctBal.xls

It errors out because there is a space in the path to the file (HBI Resources)
. I can not change the folder name. How do I modify this code so that
MsAccess recognizes it.
This is not Access issue. It is an error from the OS. Just use the
default calling convention with quotation marks as you would use on the
commandline:

Shell "excel ""fsfds"""



mfG
--> stefan <--
 
R

rfuscjr via AccessMonster.com

I wish that worked. It appears (In Access VBA for a button) you need this
format:

Dim RetVal
RetVal = Shell("EXCEL X:\Fldr1\Fldr2\'HBI Resources'\Filename.xls", 1)

****Blows up because of the space in the last folder name****

It will not let me double imbed the two sets of quotes as you suggested...
works from: START RUN but not in MsAccess VBA....ideas?

Stefan said:
hi,
RetVal = Shell("EXCEL X:\LVPG\Reports\HBI Resources\
LVPG_AR_AtbSelfpayFinalRegAcctBal.xls", 1)
[quoted text clipped - 4 lines]
. I can not change the folder name. How do I modify this code so that
MsAccess recognizes it.
This is not Access issue. It is an error from the OS. Just use the
default calling convention with quotation marks as you would use on the
commandline:

Shell "excel ""fsfds"""

mfG
--> stefan <--
 
S

Stefan Hoffmann

hi,
I wish that worked.
I've tested it before. It works for me. Maybe you need other quotes
depending on the region settings of Windows.

It appears (In Access VBA for a button) you need this
Dim RetVal
RetVal = Shell("EXCEL X:\Fldr1\Fldr2\'HBI Resources'\Filename.xls", 1)
You need to enclose the entire file name in quotes, so your version
cannot work.

Try either

Shell("EXCEL ""X:\Fldr1\Fldr2\HBI Resources\Filename.xls""", 1)

or

Shell("EXCEL 'X:\Fldr1\Fldr2\HBI Resources\Filename.xls'", 1)


mfG
--> stefan <--
 
R

rfuscjr via AccessMonster.com

Ha! I searched and after reading thru several posts I found and tried this:
MyPath = """" & "X:\Path1\Path2\HBI Resources\Path3\Filename.xls" & """"
Call Shell("EXCEL.EXE " & MyPath, 1)

It works...I am not sure why I need the 4 quotes but that appears to do the
trick; I think its similar to what you suggested.
 
S

Stefan Hoffmann

hi,
Ha! I searched and after reading thru several posts I found and tried this:
MyPath = """" & "X:\Path1\Path2\HBI Resources\Path3\Filename.xls" & """"
Call Shell("EXCEL.EXE " & MyPath, 1)

It works...I am not sure why I need the 4 quotes but that appears to do the
trick; I think its similar to what you suggested.
Yes, it is the same solution. I think you had just a typo while testing it.

mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top