I am using Borland Builder C++ 2009. I want to add a button to a form that allows the user to open a file in Excel that I specify. I can’t think of how to do this. I know how to link with other code and executables — is there a Microsoft Excel executable that I could use? How could I specify the file then? Any hints on this, or at least a place to look online, would be greatly appreciated.
Share
Assuming that the file type is registered with Excel, you could call ShellExecute() on the file, using the ‘open’ verb. This will cause the file to be opened as if double clicked by the user in Explorer and will invoke Excel.
If that isn’t the case, and you can assume that Excel is installed, you could instead pass ‘excel’ to ShellExecute() as the application, and the path of the file as the parameter. (Note that I didn’t test this, but it worked from the Run dialog, so I think that it should work from ShellExecute() as well).