Starting program with Shell

  • Thread starter Thread starter reidarT
  • Start date Start date
R

reidarT

I need to find a file (xls) and start Excel with this file
My code is
Dim Sti As String = "C:\Documents and Settings\Navn\My Documents\"
Dim Filnavn As String = "Testfile.xls"
Dim Sti2 As String = "C:\Program Files\Microsoft Office\OFFICE11\"
Dim Filnavn2 As String = "Excel.exe"
Dim StiFilnavn As String = Sti & Filnavn
Dim StiFilnavn2 As String = Sti2 & Filnavn2

If My.Computer.FileSystem.FileExists(StiFilnavn) Then
MsgBox("File found.")
Shell(StiFilnavn, AppWinStyle.NormalFocus)
...

There is something wrong with the code,
The message is Filename not found even if the FileExist says the file is
existing.
I have tried with Shell(""" & StiFilnavn & """,AppWinStyle.NormalFocus), but
it doesn't hlp

reidarT
 
reidarT said:
I need to find a file (xls) and start Excel with this file
My code is
Dim Sti As String = "C:\Documents and Settings\Navn\My Documents\"
Dim Filnavn As String = "Testfile.xls"
Dim Sti2 As String = "C:\Program Files\Microsoft Office\OFFICE11\"
Dim Filnavn2 As String = "Excel.exe"
Dim StiFilnavn As String = Sti & Filnavn
Dim StiFilnavn2 As String = Sti2 & Filnavn2

If My.Computer.FileSystem.FileExists(StiFilnavn) Then
MsgBox("File found.")
Shell(StiFilnavn, AppWinStyle.NormalFocus)
...

There is something wrong with the code,
The message is Filename not found even if the FileExist says the file is
existing.
I have tried with Shell(""" & StiFilnavn & """,AppWinStyle.NormalFocus), but
it doesn't hlp

reidarT

Have you looked at using the process class? Process.Start(Filename)
 
Back
Top