Announcement

Collapse
No announcement yet.

Curdir$ & Shell

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Manny Corrao
    replied
    Thanks Michael; I'll give it a try.

    Manny

    Leave a comment:


  • Michael Mattias
    replied
    Using the ShellExecute function, can the calling application be suspended
    No, but the link I posted above (ShellExecuteEx) does exactly that and you can use the same verbs, eg "open", "print" etc.

    from the doc for ShellExecute...
    To obtain information about the application that is launched as a result of calling ShellExecute, use ShellExecuteEx.

    Leave a comment:


  • Manny Corrao
    replied
    Originally posted by Kev Peel View Post
    Indeed, the Windows API function ShellExecute() is the one you want if your app could possibly be used on systems that use OpenOffice or another Excel replacement. It will open the associated file every time.

    Example:

    Code:
    ShellExecute %HWND_DESKTOP, "open", progpath$ + "MktgExp.csv", "", "", %SW_SHOW
    There is also function (FindExecutable) that will let you know what program a specific file type has been associated with (if any), so you could display an error message if none was found.
    Using the ShellExecute function, can the calling application be suspended until the called application is closed (similar to the SHELL statement in PowerBASIC)?

    Leave a comment:


  • Michael Mattias
    replied
    Microsoft clearly thinks little of the ability of programmers; that's about all which could explain the existence of this API:
    PathQuoteSpaces Function

    Searches a path for spaces. If spaces are found, the entire path is enclosed in quotation marks.
    MCM

    Leave a comment:


  • Manny Corrao
    replied
    Problem solved. Thanks everyone for the help.

    Manny

    Leave a comment:


  • Kev Peel
    replied
    Indeed, the Windows API function ShellExecute() is the one you want if your app could possibly be used on systems that use OpenOffice or another Excel replacement. It will open the associated file every time.

    Example:

    Code:
    ShellExecute %HWND_DESKTOP, "open", progpath$ + "MktgExp.csv", "", "", %SW_SHOW
    There is also function (FindExecutable) that will let you know what program a specific file type has been associated with (if any), so you could display an error message if none was found.

    Leave a comment:


  • Michael Mattias
    replied
    If the target file name contains a space, double-quote it.

    Or...

    If Excel is the default program for "*.csv" files on your system, you should be able to " ShellExecute" the file. ShellExecute is a WinAPI function and there should be lots of examples right here for which you can search).

    OR....
    You can replace the SHELL statement with Win 32: Monitor Process with ShellExecuteEx June 22, 2001

    That lets you put the program name and the parameter (target file) in separate variables and Windows will sort out the spaces thing.

    But I think quoting the CSV name when it contains a space should be the first thing you try.

    MCM

    Leave a comment:


  • Manny Corrao
    replied
    That worked.

    Thanks for the help.

    Manny

    Leave a comment:


  • Dale Yarker
    replied
    Try:
    SHELL(excelpath$+"EXCEL.EXE" + " " + $dq + progpath$+"MktgExp.csv" + $dq)

    That way the path is between quotes when passed to Excel's command line.

    Leave a comment:


  • Manny Corrao
    started a topic Curdir$ & Shell

    Curdir$ & Shell

    I am using PBWIN 7.02 and I am using CURDIR$ to get the path to a data file I want to open in EXCEL via SHELL. The problem is if there is a space in the name of the folder, EXCEL stops checking the string and then fails to open the file. Here is the code I am using to get the drive and path:

    ' Get the current drive
    DIM s$
    s$ = CURDIR$
    workingdrv$ = LEFT$(s$,1)

    ' Get the Program Path from s$
    progpath$ = s$+"\"

    Here is the code I am using to to SHELL to EXCEL:

    SHELL(excelpath$+"EXCEL.EXE" + " " + progpath$+"MktgExp.csv")

    Besides telling me not to use spaces in folder names, is there something more I can do?

    Thanks.

    Manny
Working...
X