Click to See Complete Forum and Search --> : opening up a file


GinnyLee
January 25th, 2000, 10:24 AM
Hello

I've made a programme that creates a file and then saves it ( according to some name the user has entered) to the desktop. What I want is to create a short cut to opening up the file from the main form. At present I've tried inserting a view command on the form but each method I've tried creates errors! Its probably something really simply but any suggestions would be great.

Thanks in advance

Johnny101
January 25th, 2000, 01:13 PM
If you know the location of the file (the full path) then you could use the ShellExecute API to have windows open that file in it's associated program. (ie .doc files open in Word etc). here is the API code...

public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(byval hwnd as Long, byval lpOperation as string, _
byval lpFile as string, byval lpParameters as string, _
byval lpDirectory as string, byval nShowCmd as Long) as Long

public Const SW_SHOWNORMAL = 1

'call it like this:
'now display the excel spreadsheet
Dim fn as string
fn = App.Path & "\myxlsfile.xls"
iRetVal = ShellExecute(me.hwnd, vbNullString, fn, vbNullString, "c:\", SW_SHOWNORMAL)




I hope this helps,
john

John Pirkey
MCSD
www.ShallowWaterSystems.com