Shelling Out

A

Alan B. Densky

Hello,

I'm trying to create a document management system using Access. It works
great with MS Word, but when I try to open an Excel file or any other file,
if there is a space in the name of the document or in the path to the
document, it bombs out. Here is a sample of my code:

If right(Me!PathToDocument, 3) = "xls" Then

stAppName = "EXCEL.EXE" & " " & Me!PathToDocument

End If


Call Shell(stAppName, 1)

I've tried the following without any success:

stAppName = "EXCEL.EXE" & " " & "'" & Me!PathToDocument & "'"

stAppName = "EXCEL.EXE & ' " & Me!PathToDocument & "'"

stAppName = "EXCEL.EXE " & "'" & Me!PathToDocument & "'"

stAppName = "EXCEL.EXE " & """ & Me!PathToDocument & """""

Thanks in advance to anyone who has the answer to this one.

Alan B. Densky
 
D

Douglas J. Steele

Try

stAppName = "EXCEL.EXE " & Chr$(34) & Me!PathToDocument & Chr$(34)

Chr$(34) is the equivalent of "
 
A

Alan B. Densky

Doug,
Excellent!!! Thank you very much!
Alan

Douglas J. Steele said:
Try

stAppName = "EXCEL.EXE " & Chr$(34) & Me!PathToDocument & Chr$(34)

Chr$(34) is the equivalent of "
 

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