• Running Shell

    Author
    Topic
    #363547

    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

    Viewing 0 reply threads
    Author
    Replies
    • #555091

      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.

      • #555267

        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

        • #555339

          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

          • #555342

            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

        • #555368

          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 this post which shows the use of the GetShortPathName API call to return a pathname without spaces. That might solve your shell problem for you.

          • #555386

            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

            • #555425

              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.

            • #555435

              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

      • #555535

        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.

        • #555538

          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

          • #555562

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

            “‘C:path 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.

            • #555574

              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

            • #555633

              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.

    Viewing 0 reply threads
    Reply To: Running Shell

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: