Exclamation[Help] Open a file automatically [VB6] [solved]

Posts 16–30 of 39 · Page 2 of 3
Youre not annoying
Did you place a "Common Dialog Control" on your form? (Project -> Components -> Microsoft Common Dialog Control 6.0)
If you tell me the error, i can help you.
So, up to now, I have selectet Project --> components --> Microsoft comm control 6.0
I have placed a button,
in the button I have this code:
Code:
Private Sub Command1_Click()
With CommonDialog1
    .FileName = ""
    .ShowOpen
    
    If .FileName <> "" Then
        RetVal = Shell("CommonDialog1.FileName", vbWindowState)
    End If
End With
End Sub
End when I run the program an error pops-up saying:
"Run-time error '424':
object required"
Quote Originally Posted by lelelololele View Post
End when I run the program an error pops-up saying:
"Run-time error '424':
object required"
You have to place the Common Dialog Control on your form and name it CommonDialog1
Ohh, well, I have done that..but, that's not what I want :/
I want to auto-open the file when I click the button..not selecting the file and then open them..
Duh guys, move on. Vb6 is outdated.
So? Its easy to learn, good for beginners.
Quote Originally Posted by Blubb1337 View Post
Duh guys, move on. Vb6 is outdated.
yea i said that already lol. vb6 is way outdated. i expect to see a vb 2011 soon
Quote Originally Posted by edub18 View Post
So? Its easy to learn, good for beginners.
So is VB.Net....well it's your decision...but believe me...every "proper" coder in this section will say so...

Ask @Hassan , @Jason , @NextGen1....
Okay you want to click a button, check if the file exists and if it exists, you want to start it?
yes..but the program will start it automatically, if it exists...NOT the user
I am sorry, but I told you I don't want to open something with a Path, that's because when someone downloads my software, the folder will be in the direction folder ( I mean where he wanted the software to be downloaded)...so it is not constant...
Code:
Dim file as string
file = "C:\Yourfile.bat"
If FileExists(file) = True Then
Shell(file, vbWindowState)
End If
And you need to paste this function:

Code:
Function FileExists(File As String) As Boolean
   On Error Resume Next
   FileExists = False
   FileExists = Dir(File) <> ""
End Function
You can get the directory of your program by using App.Path:
Code:
App.Path & "\"
Will give you something like "C:\MyProgram\"
Thanks for the source code, how ever, can I have a step by step tutorial?
pretty please :P
Tutorial? For what?
what to do exactly..I know it is a waste of time for you..but...if you have a website or something, I could mention that for credits..just, something in return :/
Posts 16–30 of 39 · Page 2 of 3
This thread is closed for replies.

Tags for this Thread

None

Talk with us