Results 1 to 14 of 14
  1. #1
    Star Lounger
    Join Date
    Oct 2001
    Location
    Western Massachusetts, USA
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Running Shell

    The following works in Win98/Office2000 but not in Win2000/OfficeXP
    Dim strAppName As String
    strAppName = "C:Program FilesMicrosoft OfficeOfficeWinword.exe"
    Call Shell (strAppName & """C:My DocumentsMy Test.doc""", 1)
    Any one have any ideas? Thanks
    Paul

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Running Shell

    Office XP wants to install in a folder called Office10. I kind of like the idea since it keeps us from stepping on other versions that are already installed.

    Try using the string "C:Program FilesMicrosoft OfficeOffice10Winword.exe" and see if that works.
    Charlotte

  3. #3
    Star Lounger
    Join Date
    Oct 2001
    Location
    Western Massachusetts, USA
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running Shell

    Thanks for looking at this Charlotte. This is the exact code used to get to Word.
    Dim stAppName
    stAppName = "C:Program FilesMicrosoft OfficeOffice10WINWORD.EXE"
    Call Shell(stAppName & """C:My DocumentsMy Test.doc""", 1)

    Bombs on error 53 File Not Found. This code works in Win98/Office2000 (changing Office10 to Office). Someone suggested I move the """ to C:"""My DocumentsMy Test.doc""" but I am trying to ferret out this problem for someone else and don't have Win2000 loaded on my machine so I can't test it. Care to help here. Thanks
    Paul

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Edmonton, Alberta, Canada
    Posts
    326
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running Shell

    I have never used Shell, so this may be way out in left field. However, I wonder if adding a space after WINWORD.EXE and before the " would help? I know you said the it worked before, but I wonder if your new system is pickier about spaces? The way you have it, there will be no space between WINWORD.EXE and the "C:My Documents... stuff

  5. #5
    Star Lounger
    Join Date
    Oct 2001
    Location
    Western Massachusetts, USA
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running Shell

    Thanks for the thought, but any space between the " marks and the Path to the file makes things worse, at least in Win98. The """ marks need to be snugged up agains the text. I don't have win2000 so I can't test any of this myself but it's unbelieveable that you would have to eliminate spaces in 2000 when you can use them in path names in 98. I'm trying to help someone on another forum and no one has been able to provide a solution.
    Thanks again
    Paul

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Running Shell

    OK, did you check to make sure that Winword.exe *is* in that location? If it is, try using short paths. I've had trouble with Shell when there were spaces in the path names, althouth it seems to me someone here in the Lounge indicated that they'd found a way to deal with that. Try using "C:Progra~1Micros~1Office10Winword.exe" for the stAppName, or substitute the appropriate number for Micros~1 if you have other folders that start like that.

    You might want to take a look at <A target="_blank" HREF=http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Cat=&Board=vb&Number=85780&page=&v iew=&sb=&o=&vc=1#Post85780>this post</A> which shows the use of the GetShortPathName API call to return a pathname without spaces. That might solve your shell problem for you.
    Charlotte

  7. #7
    Star Lounger
    Join Date
    Oct 2001
    Location
    Western Massachusetts, USA
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running Shell

    Good morning. We ended up using GetObject(). He was able to open the files he needed and that solved the problem. One of the interesting parts to this whole things is that the Path to the .exe could have spaces in it. It was the Path to the .doc file that bombed with spaces. I haven't found the answer but I don't need this to go any further because he's going a different route, thanks for the suggestions.
    Paul

  8. #8
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Running Shell

    Glad you found somethign that worked. I've run into the same problem with the path to the database file when using Shell that way. Since it wasn't critical, I didn't pursue it. Maybe I'll take another shot at it.
    Charlotte

  9. #9
    Star Lounger
    Join Date
    Oct 2001
    Location
    Western Massachusetts, USA
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running Shell

    At this point I'd be interested simply because it doesn't make sense that you can do it in win98 but you can't in 2000.
    Thanks
    Paul

  10. #10
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Altnau, Thurgau, Switzerland
    Posts
    447
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running Shell

    Look at the registry - HKEY_LOCAL_MACHINE with the key SOFTWAREMicrosoftwindowscurrentversionApp PathsWinWord.EXE
    This should be safer than hardcoding the path should the user have not selected the defaults during the installation.

  11. #11
    Star Lounger
    Join Date
    Oct 2001
    Location
    Western Massachusetts, USA
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running Shell

    That's a great alternative. Thanks. The problem we are having is with the .doc path and not the .exe path. It seems that you can have spaces in the .exe path without problems arising. It's when you have spaces in the path to the .doc file that you error out. In Win98 """C:My DocumentsMy Text.doc""" works, but the same line in Win2000 doesn't. We've been looking for anything that does work.
    Paul

  12. #12
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Altnau, Thurgau, Switzerland
    Posts
    447
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running Shell

    Try something like (construct as a string prior to the shell command)

    "'Cath to winwordwinword.exe' 'C:My DocumentsMy Text.doc'"

    Note the single spaces. (I use Win2000 and can open documents/other files with a space in the path using code).

    A general point. Also consider the CreateProcess call (Windows API). It's a pig to use but you have far more control than with the shell command. For example you can force Access to wait until the 'shelled' process has finished.

  13. #13
    Star Lounger
    Join Date
    Oct 2001
    Location
    Western Massachusetts, USA
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running Shell

    Wonderful. That's about the only combination of single and double quotes I didn't try. Thanks for taking the time to clear this up. I appreciate it a lot.
    Paul

  14. #14
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Altnau, Thurgau, Switzerland
    Posts
    447
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Running Shell

    Your welcome. I had this problem with spaces in paths some years ago to solve. It's easy (as is most stuff) when you know how.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •