Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Files from PB

Status
Not open for further replies.

late2town

Programmer
Dec 10, 2009
4
US
I want to open a file from my local directory thru an open button on my PB app screen. The file should get opened by the default program depending on the extension. Like .xls, .csv should get opened in excel, .doc in word and .txt in Notepad. I tried FileOpen function but it is not working, though after my fileopen is executed in the debugger if I try to access the file its saying its been locked by some program(which is my PB app I guess). Please post a solution.
 
check out this next link it's perfect to explain the use of ShellExecute:!

the only problem I've found doing something like previous code: if for example you're viewing at a certain time a certain web-page in your default internet browser, that instance will be replaced with the one issued with your ShellExecute. (if your user was viewing a page that has nothing to do with the pb application, it'll be replaced). I think this happens also with other applications, as Word, Excell, etc. I don't know if it might be avoided, changing one of the parameters of the funtion call ("..." instead of "Open" ???)


If this supposes a problem: Try to use the Run( ) command.
By default windows will check the program asociated with it.
Try to run:

Run( "c:\mytextfile.txt" )

instead of

run ("notepad.exe c:\mytextfile.txt")

and see if it works. (I can't try it myself since I don't have PB installed at the moment),

Miguel


regards,
Miguel L.
 
Just to explain the use of FileOpen() (which correctly didn't serve your purpose).

FileOpen() is used to get access to a file and then read/write bytes from/to it, by using FileRead(Ex) and FileWrite(Ex). (when you finish you close the access to the file with fileclose() )

What you want to do is something else:
'execute the aplication associated to a certain file', passing the file as the 'archive' to be opened by that application.


regards,
Miguel L.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top