Results 1 to 5 of 5

Thread: File Assositation, Opening file

  1. #1

    Thread Starter
    Frenzied Member I_Love_My_Vans's Avatar
    Join Date
    Jan 2005
    Location
    In the PHP compiler
    Posts
    1,275

    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

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    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:
    1. Private Sub Form_Load()
    2.     Dim sFileName As String
    3.     sFileName = Command$
    4.     If Len(sFileName) Then
    5.         'we have some info from the command line
    6.         OpenFile sFileName
    7.         'The above assumes that you already have a Sub/Function called OpenFile
    8.         'that will open the passed file name.
    9.     End If
    10. End Sub

  3. #3

    Thread Starter
    Frenzied Member I_Love_My_Vans's Avatar
    Join Date
    Jan 2005
    Location
    In the PHP compiler
    Posts
    1,275

    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

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: File Assositation, Opening file

    Oh yeah, Windows pass the filename enclosed by quotation marks, just remove them first.
    VB Code:
    1. Private Sub Form_Load()
    2.     Dim sFileName As String
    3.     sFileName = Command$
    4.     If Len(sFileName) Then
    5.         'we have some info from the command line
    6. [b]        sFileName = Replace(sFileName, """", "") [/b]  
    7.         OpenFile sFileName
    8.         'The above assumes that you already have a Sub/Function called OpenFile
    9.         'that will open the passed file name.
    10.     End If
    11. End Sub

  5. #5

    Thread Starter
    Frenzied Member I_Love_My_Vans's Avatar
    Join Date
    Jan 2005
    Location
    In the PHP compiler
    Posts
    1,275

    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
  •  



Click Here to Expand Forum to Full Width