+ Reply to Thread
Results 1 to 8 of 8

New Excel Instance

Hybrid View

  1. #1
    Registered User
    Join Date
    04-13-2005
    Posts
    11

    New Excel Instance

    Does anybody know how to start a new excel instance from Excel VBA?
    I have a macro that can take a while to complete so I want to hide the application whilst it runs. I want the macro to start Excel as a new process in Task Manager and then hide this.
    I am using different versions of Excel as well from Excel 2000 to 2003.
    Any ideas anybody?

  2. #2
    Forum Contributor
    Join Date
    04-11-2005
    Location
    London
    Posts
    259
    This'll do it

    Sub NewInstance()
        Call Shell("C:\Program Files\Microsoft Office\Office10\Excel.Exe", vbHide)
    End Sub
    I've used vbHide here, but there are a number of different options available.

  3. #3
    Registered User
    Join Date
    04-13-2005
    Posts
    11
    Is it possible to open an excel file using this command?

  4. #4
    Forum Contributor
    Join Date
    04-11-2005
    Location
    London
    Posts
    259
    Yup.

    Sub test()
        Call Shell("C:\Program Files\Microsoft Office\Office10\Excel.Exe c:\fred", vbMaximizedFocus)
    End Sub
    You just add the filename as a parameter at the end of the path.

    Hope this helps

    MS
    Last edited by MartinShort; 04-14-2005 at 04:36 AM.

  5. #5
    Registered User
    Join Date
    04-13-2005
    Posts
    11
    I tried to do this and it works upto the path name bit.
    The pathname I use has a space in it, and it reports an error. I think it sees it as two arguments. Do you know a way around this, apart from moving the file?

  6. #6
    Forum Contributor
    Join Date
    04-11-2005
    Location
    London
    Posts
    259
    I thought you'd beaten me for a minute as using double quotes, single quotes, variable names doesn't do what you want.

    However, I just tried creating a shortcut without any spaces pointing at a folder with spaces in the pathname and it works by rerouting your pathname to the shortcut as in my example below.

    eg.
    Sub test()
        Call Shell("C:\Program Files\Microsoft Office\Office10\Excel.Exe c:\tom.xls.lnk", vbMaximizedFocus)
    End Sub
    Enjoy
    MS

  7. #7
    Registered User
    Join Date
    04-13-2005
    Posts
    11

    Smile

    Brilliant idea using shortcuts.
    I used the code and it works beautifully.
    Thank you, you have jsut stopped me turning into a crazy man.

  8. #8
    Forum Contributor
    Join Date
    04-11-2005
    Location
    London
    Posts
    259
    No problem. (I think I lost the plot on the crazy stakes some years ago - just give in and go with the flow )

    Glad I could help

    MS

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1