-
I want to double click on a file(lets say a *.txt file) and get it to launch my program(lets say a text editor that has a rich text box to load a file into) and have it load the file right into the rich text box with out the user doing anything other than double clicking the original file?
thanks yall
-
Why don't you write your app' so that it takes the file name as a commandline arguement.
then simply associate the file type u want with your application, using the standard windows method?
Or am i missing something??? :)
Cheers
-
This function will return all command parameters in a variant that contains an array:
Function GetCommandLine(Optional MaxArgs)
'Declare variables.
Dim C, CmdLine, CmdLnLen, InArg, i, NumArgs
'See if MaxArgs was provided.
If IsMissing(MaxArgs) Then MaxArgs = 10
'Make array of the correct size.
ReDim argarray(MaxArgs)
NumArgs = 0: InArg = False
'Get command line arguments.
CmdLine = Command()
CmdLnLen = Len(CmdLine)
'Go thru command line one character
'at a time.
For i = 1 To CmdLnLen
C = Mid(CmdLine, i, 1)
'Test for space or tab.
If (C <> " " And C <> vbTab) Then
'Neither space nor tab.
'Test if already in argument.
If Not InArg Then
'New argument begins.
'Test for too many arguments.
If NumArgs = MaxArgs Then Exit For
NumArgs = NumArgs + 1
InArg = True
End If
'Concatenate character to current argument.
argarray(NumArgs) = argarray(NumArgs) & C
Else
'Found a space or tab.
'Set InArg flag to False.
InArg = False
End If
Next i
'Resize array just enough to hold arguments.
ReDim Preserve argarray(NumArgs)
'Return Array in Function name.
GetCommandLine = argarray()
End Function
-
"Why don't you write your app' so that it takes the file name as a commandline arguement."
that exactly what i would like to do, but im not sure how to do it and what i need to do.
-
Copy the function in my last post and put this in your form_load event:
For Each n In GetCommandLine
If Not IsEmpty(n) Then Loadfile n: Exit For
Next n
And if you're making an MDI app, remove the Exit for. Rename Loadfile method, for whatever your method is to load the file.
Hope you get things work now! :)