The code above shows the error that the file does not exist. But it exists. I tried the same code for an .exe file it works great. Any ideas?Code:Shell(Application.StartupPath & "\myfile.txt", vbMaximized Focus)
Printable View
The code above shows the error that the file does not exist. But it exists. I tried the same code for an .exe file it works great. Any ideas?Code:Shell(Application.StartupPath & "\myfile.txt", vbMaximized Focus)
try this:
vb Code:
Shell(Application.StartupPath & "\myfile.txt", vbMaximized Focus)
sorry i added one more quote next to application.startuppath. the code you gave is what i have but nothing.
ok. debug.print(Application.StartupPath & "\myfile.txt") + check the path is right
the path is absolutely correct!
ok.
vb Code:
msgbox(io.file.exists(Application.StartupPath & "\myfile.txt"))
it returns true. it found the file. :S but shell still dead
in vb6 the same code would be like that:
but Explorer.exe does not seem to work in vb2010.Code:Shell("Explorer.exe " & App.Path & "\myfile.txt", vbMaximized Focus)
Shell is legacy + not used in vb.net
search for the Process class, in particular Process.Start
FIle Code:
Dim _filepath$ = Application.StartupPath & "\myfile.txt" Process.Start(_filepath)
proccess.start works great! i tried to add vbMaximizedFocus in procress.start but no result. doesn't it accept that commands?
here ya go, all process start arguments you could use. There are more, but I left those out that you would probably not use. :bigyello:
vb Code:
Dim p As New Process With p.StartInfo .FileName = "file name" .Arguments = "arguments" .CreateNoWindow = False .WindowStyle = ProcessWindowStyle.Maximized 'minimized, maximized, normal, hidden .WorkingDirectory = "directory of where the application is when started" .UseShellExecute = True 'Use shell to start any file, esp. important for "open with" files .ErrorDialog = True 'show error dialog if failed to start End With p.Start() 'start the process p.WaitForExit() 'optional: stop code execution until the process exited (closed)
Not sure about the focus command, but usually newly created windows will take focus any ways. :thumb: