Home All Groups Group Topic Archive Search About

Starting program with Shell

Author
13 Aug 2006 9:55 AM
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

Author
13 Aug 2006 6:36 PM
Chris
reidarT wrote:
Show quoteHide quote
> 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)