Results 1 to 5 of 5

Thread: [RESOLVED] Shell command returns file not found error

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2021
    Posts
    6

    Resolved [RESOLVED] Shell command returns file not found error

    Hi,

    Well, like the title says, the shell command suddenly stopped working. Yes, it worked before, and no, I have not changed anything since then. Actually I'm not sure I've even used the computer in between.

    I use the shell command to start excel 2003, since a later version of the program corrupted the references so that VS starts the later version (I have a separate thread for that problem, I believe this problem is a different one).

    Now the shell command cannot find the excel.exe file.

    Yes, it´s there and yes, it works when I click it manually and when calling it from the command prompt.

    Does anyone have any ideas? It would be greatly appreciated.

    /VB

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: Shell command returns file not found error

    Asking us to help you fix code that you haven't shown us is not a great start. If you are actually using Shell then don't. This is not VB6. Use Process.Start. Change the code as appropriate and then post all the relevant information if that doesn;t work.

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2021
    Posts
    6

    Re: Shell command returns file not found error

    Thanks for answering.

    I´m using this to reference an instance of excel 2003 (separate thread for this), because I also have Office365 installed.

    When using shell (until today), it works.

    When using process.start, I have to click the UAC control (Apparantly I need to run excel as admin (other thread)), and the GetObject() method doesn't work.

    Code:
        Public Function GetExcel()
            Dim xl As Object
            Dim intsection As Integer
            Dim inttries As Integer
            'Shell("C:\Path\Excel.exe", AppWinStyle.MinimizedFocus)
            Process.Start("C:\Path\Excel.exe")
            Interaction.AppActivate("MyProgram")
            On Error GoTo ErrorHandler
            intsection = 1
            xl = GetObject(, "Excel.Application")
            intsection = 0
            Return xl
            Exit Function
    ErrorHandler:
            If intsection = 1 Then
                Resume 
            End If
        End Function
    Thanks /VB

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: Shell command returns file not found error

    That code looks like it was written in VB6 originally so that would explain why you were using Shell. I wonder whether the UAC prompt when using Process.Start is just a different manifestation of the same set of circumstances that is preventing Shell working. It may have something to do with Windows virtualising a folder and/or 32/64-bit mapping. I don't work much with Office so I can't really offer too much insight, I'm afraid.

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2021
    Posts
    6

    Re: Shell command returns file not found error

    Hi again,

    Thanks for answering. I thought I should share this information.

    I took a chance and changed back the admin mode for excel 2003 and all of a sudden it works. So, the shell method works when visual studio runs in admin mode and excel doesn´t.

    VB

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width