Always Open in New Instance

Discussion in 'Microsoft Excel Misc' started by Guest, Sep 7, 2007.

  1. Guest

    Guest Guest

    I have an Excel workbook that uses userforms and save/close procedures
    extensively to automate some processes. I need this workbook to always open
    in a new instance of Excel. If the user already has a workbook open, opening
    this file will open in the instance that is already open, which I don't want.
    Is there any VBA code that will force this to happen? Much appreciated!
    --
    Thanks,

    Gerry O.
     
    Guest, Sep 7, 2007
    #1
    1. Advertisements

  2. Guest

    Guest Guest

    Here is some code to make spreadsheets open up in new instances...

    Application.IgnoreRemoteRequests = True
    'Open your file
    Application.IgnoreRemoteRequests = False

    Note that what this is doing is it is toggling the setting
    Tools|Options -> General ->Ignore Other Applications
    --
    HTH...

    Jim Thomlinson


    "Gerry O" wrote:

    > I have an Excel workbook that uses userforms and save/close procedures
    > extensively to automate some processes. I need this workbook to always open
    > in a new instance of Excel. If the user already has a workbook open, opening
    > this file will open in the instance that is already open, which I don't want.
    > Is there any VBA code that will force this to happen? Much appreciated!
    > --
    > Thanks,
    >
    > Gerry O.
     
    Guest, Sep 7, 2007
    #2
    1. Advertisements

  3. Guest

    Guest Guest

    Thanks, Jim. I know this works if you open the Excel file with the code
    first. However, if a user already has a workbook open, opening this file
    will open in the same instance as the existing workbook, rather than a new
    instance. I am trying to get my workbook to always open in a new instance of
    Excel and was hoping to find the code for it. Possibly need a shell file
    that runs a macro to fire my workbook into a new instance? Not sure of the
    coding though.
    --
    Thanks,

    Gerry O.


    "Jim Thomlinson" wrote:

    > Here is some code to make spreadsheets open up in new instances...
    >
    > Application.IgnoreRemoteRequests = True
    > 'Open your file
    > Application.IgnoreRemoteRequests = False
    >
    > Note that what this is doing is it is toggling the setting
    > Tools|Options -> General ->Ignore Other Applications
    > --
    > HTH...
    >
    > Jim Thomlinson
    >
    >
    > "Gerry O" wrote:
    >
    > > I have an Excel workbook that uses userforms and save/close procedures
    > > extensively to automate some processes. I need this workbook to always open
    > > in a new instance of Excel. If the user already has a workbook open, opening
    > > this file will open in the instance that is already open, which I don't want.
    > > Is there any VBA code that will force this to happen? Much appreciated!
    > > --
    > > Thanks,
    > >
    > > Gerry O.
     
    Guest, Sep 8, 2007
    #3
  4. Guest

    iliace Guest

    Put this code in the loader workbook's ThisWorkbook module:

    Private Sub Workbook_Open()
    Const strPath As String = "C:\myWorkbook.xls"

    Dim xl As Excel.Application

    Set xl = New Excel.Application

    xl.Workbooks.Open (strPath)

    xl.Visible = True

    Me.Close
    End Sub

    Change the constant at the top to reflect where your file is located.


    On Sep 8, 1:28 am, Gerry O <> wrote:
    > Thanks, Jim. I know this works if you open the Excel file with the code
    > first. However, if a user already has a workbook open, opening this file
    > will open in the same instance as the existing workbook, rather than a new
    > instance. I am trying to get my workbook to always open in a new instance of
    > Excel and was hoping to find the code for it. Possibly need a shell file
    > that runs a macro to fire my workbook into a new instance? Not sure of the
    > coding though.
    > --
    > Thanks,
    >
    > Gerry O.
    >
    >
    >
    > "Jim Thomlinson" wrote:
    > > Here is some code to make spreadsheets open up in new instances...

    >
    > > Application.IgnoreRemoteRequests = True
    > > 'Open your file
    > > Application.IgnoreRemoteRequests = False

    >
    > > Note that what this is doing is it is toggling the setting
    > > Tools|Options -> General ->Ignore Other Applications
    > > --
    > > HTH...

    >
    > > Jim Thomlinson

    >
    > > "Gerry O" wrote:

    >
    > > > I have an Excel workbook that uses userforms and save/close procedures
    > > > extensively to automate some processes. I need this workbook to always open
    > > > in a new instance of Excel. If the user already has a workbook open, opening
    > > > this file will open in the instance that is already open, which I don't want.
    > > > Is there any VBA code that will force this to happen? Much appreciated!
    > > > --
    > > > Thanks,

    >
    > > > Gerry O.- Hide quoted text -

    >
    > - Show quoted text -
     
    iliace, Sep 8, 2007
    #4
  5. Guest

    Guest Guest

    Thanks - that did the trick! I've thought of an additional way to improve
    what I am doing. Do you happen to know any code that will check to see if an
    instance of Excel is already open or not? If one isn't open, I can open my
    workbook in the same instance brought up by the "opener" workbook. If one is
    already open, it forces a new instance. The workbook I want to open has code
    "Application.IgnoreRemoteRequests = True", so any additional workbooks opened
    while that one is open will be forced into a new instance. Sorry to add
    another question!
    --
    Thanks,

    Gerry O.


    "iliace" wrote:

    > Put this code in the loader workbook's ThisWorkbook module:
    >
    > Private Sub Workbook_Open()
    > Const strPath As String = "C:\myWorkbook.xls"
    >
    > Dim xl As Excel.Application
    >
    > Set xl = New Excel.Application
    >
    > xl.Workbooks.Open (strPath)
    >
    > xl.Visible = True
    >
    > Me.Close
    > End Sub
    >
    > Change the constant at the top to reflect where your file is located.
    >
    >
    > On Sep 8, 1:28 am, Gerry O <> wrote:
    > > Thanks, Jim. I know this works if you open the Excel file with the code
    > > first. However, if a user already has a workbook open, opening this file
    > > will open in the same instance as the existing workbook, rather than a new
    > > instance. I am trying to get my workbook to always open in a new instance of
    > > Excel and was hoping to find the code for it. Possibly need a shell file
    > > that runs a macro to fire my workbook into a new instance? Not sure of the
    > > coding though.
    > > --
    > > Thanks,
    > >
    > > Gerry O.
    > >
    > >
    > >
    > > "Jim Thomlinson" wrote:
    > > > Here is some code to make spreadsheets open up in new instances...

    > >
    > > > Application.IgnoreRemoteRequests = True
    > > > 'Open your file
    > > > Application.IgnoreRemoteRequests = False

    > >
    > > > Note that what this is doing is it is toggling the setting
    > > > Tools|Options -> General ->Ignore Other Applications
    > > > --
    > > > HTH...

    > >
    > > > Jim Thomlinson

    > >
    > > > "Gerry O" wrote:

    > >
    > > > > I have an Excel workbook that uses userforms and save/close procedures
    > > > > extensively to automate some processes. I need this workbook to always open
    > > > > in a new instance of Excel. If the user already has a workbook open, opening
    > > > > this file will open in the instance that is already open, which I don't want.
    > > > > Is there any VBA code that will force this to happen? Much appreciated!
    > > > > --
    > > > > Thanks,

    > >
    > > > > Gerry O.- Hide quoted text -

    > >
    > > - Show quoted text -

    >
    >
    >
     
    Guest, Sep 9, 2007
    #5
  6. Guest

    Guest Guest

    Think I figured it out. Used the following code and seems to work perfectly
    for my purposes. Thanks again!

    Private Sub Workbook_Open()

    Dim xl As Excel.Application
    Dim I As Integer
    Const strPath As String = "C:\test2.xls"
    Set xl = New Excel.Application
    I = 0

    xl.Workbooks.Open (strPath)
    xl.Visible = True

    For Each wb In Workbooks
    I = I + 1
    Next wb

    If I > 1 Then
    Me.Close
    Else
    Application.Quit
    End If

    End Sub

    --
    Thanks,

    Gerry O.


    "iliace" wrote:

    > Put this code in the loader workbook's ThisWorkbook module:
    >
    > Private Sub Workbook_Open()
    > Const strPath As String = "C:\myWorkbook.xls"
    >
    > Dim xl As Excel.Application
    >
    > Set xl = New Excel.Application
    >
    > xl.Workbooks.Open (strPath)
    >
    > xl.Visible = True
    >
    > Me.Close
    > End Sub
    >
    > Change the constant at the top to reflect where your file is located.
    >
    >
    > On Sep 8, 1:28 am, Gerry O <> wrote:
    > > Thanks, Jim. I know this works if you open the Excel file with the code
    > > first. However, if a user already has a workbook open, opening this file
    > > will open in the same instance as the existing workbook, rather than a new
    > > instance. I am trying to get my workbook to always open in a new instance of
    > > Excel and was hoping to find the code for it. Possibly need a shell file
    > > that runs a macro to fire my workbook into a new instance? Not sure of the
    > > coding though.
    > > --
    > > Thanks,
    > >
    > > Gerry O.
    > >
    > >
    > >
    > > "Jim Thomlinson" wrote:
    > > > Here is some code to make spreadsheets open up in new instances...

    > >
    > > > Application.IgnoreRemoteRequests = True
    > > > 'Open your file
    > > > Application.IgnoreRemoteRequests = False

    > >
    > > > Note that what this is doing is it is toggling the setting
    > > > Tools|Options -> General ->Ignore Other Applications
    > > > --
    > > > HTH...

    > >
    > > > Jim Thomlinson

    > >
    > > > "Gerry O" wrote:

    > >
    > > > > I have an Excel workbook that uses userforms and save/close procedures
    > > > > extensively to automate some processes. I need this workbook to always open
    > > > > in a new instance of Excel. If the user already has a workbook open, opening
    > > > > this file will open in the instance that is already open, which I don't want.
    > > > > Is there any VBA code that will force this to happen? Much appreciated!
    > > > > --
    > > > > Thanks,

    > >
    > > > > Gerry O.- Hide quoted text -

    > >
    > > - Show quoted text -

    >
    >
    >
     
    Guest, Sep 9, 2007
    #6
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roger Settle

    Open a new instance

    Roger Settle, Apr 28, 2004, in forum: Microsoft Excel Misc
    Replies:
    6
    Views:
    155
    David Benson
    Apr 29, 2004
  2. Sean

    Open Excel in New Instance

    Sean, Jun 18, 2004, in forum: Microsoft Excel Misc
    Replies:
    7
    Views:
    255
    Dave Peterson
    Jun 19, 2004
  3. Guest
    Replies:
    1
    Views:
    181
    papou
    Feb 21, 2005
  4. Mark
    Replies:
    4
    Views:
    248
  5. Jon Peltier

    Re: Open new instance of excel every time I click file

    Jon Peltier, Dec 28, 2006, in forum: Microsoft Excel Misc
    Replies:
    2
    Views:
    924
Loading...

Share This Page