How do I open an xls file I exported from a command button?

I have successfully figured out how to export a selected portion of a table to an xls file ( :) ) from a command button. The icing on the cake would be for it to also automatically open the sheet for viewing by the user. I have figured out how to do this via a hyperlink, but now there's an additional click involved and it doesn't seem as elegant. Any ideas Thanks!




Answer this question

How do I open an xls file I exported from a command button?

  • Fabio Vazquez

    wait! Nevermind! I figured it out...okay, well in reality I found an example that works...

    EXPORT TO C:\sold.XLS XLS

    ox=CREATEOBJECT("excel.application")

    ox.Visible=.t.

    ox.Workbooks.Open("c:\sold.xls")



  • Bogdan.B

    Your example uses COM Automation to open an instance of Excel as an object to be able to manipulate it. You have a reference to Excel ("ox") that you have to clean up later:

    RELEASE ox

    or

    ox = NULL

    Another way that may work for you is to launch the associated app. That creates a separate entity, not tied as an object reference:

    DECLARE INTEGER ShellExecute IN SHELL32.DLL ;
    INTEGER nWinHandle, STRING cOperation, STRING cFileName,;
    STRING cParameters, STRING cDirectory, LONG nShowWindow

    ShellExecute(0,"Open","sold.xls","","c:\",0)

    HTH


  • How do I open an xls file I exported from a command button?