|
-
Nov 6th, 2005, 06:55 AM
#1
Thread Starter
Frenzied Member
File Assositation, Opening file
I have a file assosiation, and i want my users to be able to click the file and it will open up my app with the contents of that file loaded.
Cheers // ILMV
-
Nov 6th, 2005, 07:26 AM
#2
Re: File Assositation, Opening file
If the file is already associated with your application Windows will open your app and pass the file name and path to it on the command line. So you just have to call the code you're already using to open a known file and pass the Command$ string.
VB Code:
Private Sub Form_Load()
Dim sFileName As String
sFileName = Command$
If Len(sFileName) Then
'we have some info from the command line
OpenFile sFileName
'The above assumes that you already have a Sub/Function called OpenFile
'that will open the passed file name.
End If
End Sub
-
Nov 6th, 2005, 08:17 AM
#3
Thread Starter
Frenzied Member
Re: File Assositation, Opening file
Im getting an error, i can load up my file when the program is running, but it doesnt load from the file in windows?
i get the error "52: bad file name or number"
:S
-
Nov 6th, 2005, 08:41 AM
#4
Re: File Assositation, Opening file
Oh yeah, Windows pass the filename enclosed by quotation marks, just remove them first.
VB Code:
Private Sub Form_Load()
Dim sFileName As String
sFileName = Command$
If Len(sFileName) Then
'we have some info from the command line
[b] sFileName = Replace(sFileName, """", "") [/b]
OpenFile sFileName
'The above assumes that you already have a Sub/Function called OpenFile
'that will open the passed file name.
End If
End Sub
-
Nov 6th, 2005, 08:44 AM
#5
Thread Starter
Frenzied Member
Re: File Assositation, Opening file
WOOO!!! cheers mate
ILMV
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|