Call Shell to Excel issue

P

Piri

Access 97
I am creating an xls file using:
DoCmd.TransferSpreadsheet acExport, 8, "PartsUsed4Period", FilePath &
FileName

where the FilePath has been a string without spaces, and Filename is the
name given to the spreadsheet, that name depending on certain criteria.
I sometimes add further tables (worksheets) to that xls file.

I have been successfully using the following to open the spreadsheet
after creating it:

Call Shell("C:\Program Files\Microsoft Office\Office\EXCEL.EXE " &
FilePath & FileName, 1)
where the Excel app version is from the Office 97 suite.

That has worked fine.

I am now trying to open this spreadsheet using
Call Shell("C:\Program Files\Microsoft Office 2000\Office\EXCEL.EXE " &
FilePath & FileName, 1)
where the Excel app is from the Office 2000 suite.

It seems not to like the fact that the new FilePath includes a space in
the directory name, and sees, for example "C:\John
Smith\Reports\ThisReport.xls" as two files to open, namely

"C:\John.xls" and then "Smith\Reports\ThisReport.xls"

I cannot change the directory name.

Is there a way I can have the latter call accept spaces in a directory name?

Thanks for any assistance.

Piri
 
R

RoyVidar

Piri wrote in message said:
Access 97
I am creating an xls file using:
DoCmd.TransferSpreadsheet acExport, 8, "PartsUsed4Period", FilePath &
FileName

where the FilePath has been a string without spaces, and Filename is the name
given to the spreadsheet, that name depending on certain criteria.
I sometimes add further tables (worksheets) to that xls file.

I have been successfully using the following to open the spreadsheet after
creating it:

Call Shell("C:\Program Files\Microsoft Office\Office\EXCEL.EXE " & FilePath &
FileName, 1)
where the Excel app version is from the Office 97 suite.

That has worked fine.

I am now trying to open this spreadsheet using
Call Shell("C:\Program Files\Microsoft Office 2000\Office\EXCEL.EXE " &
FilePath & FileName, 1)
where the Excel app is from the Office 2000 suite.

It seems not to like the fact that the new FilePath includes a space in the
directory name, and sees, for example "C:\John Smith\Reports\ThisReport.xls"
as two files to open, namely

"C:\John.xls" and then "Smith\Reports\ThisReport.xls"

I cannot change the directory name.

Is there a way I can have the latter call accept spaces in a directory name?

Thanks for any assistance.

Piri

Try enclosing the path and file name with a couple of extra quotes

....\Office\EXCEL.EXE " & chr$(34) & FilePath & FileName & chr$(34), 1)
 
P

Piri

Thanks RoyVidar,
That did the trick.

Piri
Try enclosing the path and file name with a couple of extra quotes

...\Office\EXCEL.EXE " & chr$(34) & FilePath & FileName & chr$(34), 1)
 

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

Similar Threads

Problem with Call Shell 10
close shell issue 0
shell 2
Using Shell to open Excel file 1
Opening text export file using call shell command 5
shell command 2
Shell 4
shell to run another mdb 4

Top