Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell Function Permissions Issue

Status
Not open for further replies.

krissrites

Programmer
Nov 22, 2007
19
CA
Hey,

I'm working on an Access 2003 db and I'm having a problem with the Shell Function. I'm using the function to open a Word document.

stAppName = "WINWORD.EXE C:\Documents and Settings\ChartrandC1\My Documents\DialogTest.doc"
Call Shell(stAppName, 1)

When this runs I get an error message - Word experienced a problem opening this file ... check that it exists ... you may not have sufficient permission ...

I know I have permission and that the file exists. If I try the same code with a word document on the C: Drive, it works fine.

Thanks in advance for you help

Chris
 
Most likely its because you have a space in the path. Put the path in quote marks and try again, eg:

stAppName = "WINWORD.EXE ""C:\Documents and Settings\ChartrandC1\My Documents\DialogTest.doc"" "

Next thing to check if there's still a problem, is if the current user has permission to access that document (NTFS permission on the disk could lock current user out of another user's my documents folder).

John
 
OK, so I found out why. It will not open the file if there is a space anywhere in the file path, possibly in the file name as well.

That isn't very helpful when there are folder paths that by Default have spaces in em like "My Documents" for example.

Anyone deal with that problem before?

Chris
 
Yes - that's how I knew the answer off the top of my head.

Another way of resolving this is to use the old 8 character filename, it will be something like:

"WINWORD.EXE C:\Docume~1\Chartr~1\MyDocu~1\Dialog~1.doc"

Use dir /x from the command prompt to see the old 8.3 style filenames.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top