|
-
Apr 3rd, 2011, 02:03 PM
#1
Thread Starter
Addicted Member
Text File Shell does not work
Code:
Shell(Application.StartupPath & "\myfile.txt", vbMaximized Focus)
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?
Last edited by systemous; Apr 3rd, 2011 at 02:12 PM.
-
Apr 3rd, 2011, 02:10 PM
#2
Re: Text File Shell does not work
try this:
vb Code:
Shell(Application.StartupPath & "\myfile.txt", vbMaximized Focus)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Apr 3rd, 2011, 02:12 PM
#3
Thread Starter
Addicted Member
Re: Text File Shell does not work
sorry i added one more quote next to application.startuppath. the code you gave is what i have but nothing.
-
Apr 3rd, 2011, 02:14 PM
#4
Re: Text File Shell does not work
ok. debug.print(Application.StartupPath & "\myfile.txt") + check the path is right
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Apr 3rd, 2011, 02:15 PM
#5
Thread Starter
Addicted Member
Re: Text File Shell does not work
the path is absolutely correct!
-
Apr 3rd, 2011, 02:17 PM
#6
Re: Text File Shell does not work
ok.
vb Code:
msgbox(io.file.exists(Application.StartupPath & "\myfile.txt"))
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Apr 3rd, 2011, 03:39 PM
#7
Thread Starter
Addicted Member
Re: Text File Shell does not work
it returns true. it found the file. :S but shell still dead
-
Apr 4th, 2011, 05:14 AM
#8
Thread Starter
Addicted Member
Re: Text File Shell does not work
in vb6 the same code would be like that:
Code:
Shell("Explorer.exe " & App.Path & "\myfile.txt", vbMaximized Focus)
but Explorer.exe does not seem to work in vb2010.
-
Apr 4th, 2011, 08:15 AM
#9
Re: Text File Shell does not work
Shell is legacy + not used in vb.net
search for the Process class, in particular Process.Start
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Apr 4th, 2011, 09:50 AM
#10
Addicted Member
Re: Text File Shell does not work
FIle Code:
Dim _filepath$ = Application.StartupPath & "\myfile.txt"
Process.Start(_filepath)
-
Apr 5th, 2011, 08:21 AM
#11
Thread Starter
Addicted Member
Re: Text File Shell does not work
proccess.start works great! i tried to add vbMaximizedFocus in procress.start but no result. doesn't it accept that commands?
-
Apr 5th, 2011, 02:50 PM
#12
Fanatic Member
Re: Text File Shell does not work
here ya go, all process start arguments you could use. There are more, but I left those out that you would probably not use. 
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.
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
|