+ Reply to Thread
Results 1 to 2 of 2

opening form in new instance of excel

  1. #1
    riva91
    Guest

    opening form in new instance of excel

    I've been exploring alot of threads about this subject but haven't
    found the right solution yet.

    My problem is that i have an excel sheet with a vba form uploaded on
    our intranet. When a user downloads this file and immediately opens it,
    it wil open the form through the workbook_open event.
    No problem so far.
    But when this user has already an instance of excel running the
    userform opens on the background in this instance and is not always in
    focus.

    What i want is to open this form in a new instance of excel if excel
    is already running. I found a function that tests if excel is running.
    But how can i control this workbook being opened in a new instance?
    When i use the workbook_open event the choice has already been made for
    me.

    Anyone a good idea?

    This is in dummy code what i want

    If fIsAppRunning("Excel") Then
    Set objXL = CreateObject("Excel.Application")
    frmEAED.Show ' to open this form in the objXL instance



    Regards,

    Bert Nijkoops


  2. #2
    Peter T
    Guest

    Re: opening form in new instance of excel

    Hi Bert,

    You can of course start a new Excel instance, possibly within that opening a
    copy of your project with form to auto run. But that would not only be
    another instance of Excel but another 'instance' (for want of a better word)
    of your project with userform.

    I can't replicate your intranet scenario but there are ways to ensure 'your'
    excel application is both visible and the front window, perhaps with API's

    Private Declare Function FindWindowA Lib "user32" _
    (ByVal lpClasssName As String, _
    ByVal lpWindowName As String) As Long

    Private Declare Function SetForegroundWindow Lib "user32" _
    (ByVal hwnd As Long) As Long

    Dim appHwin As Long

    Sub AppToFront()
    'Application.Visible = True ' ?

    appHwin = FindWindowA(vbNullString, Application.Caption)

    SetForegroundWindow appHwin

    End Sub

    Not sure but perhaps even simpler with AppActivate, eg

    AppActivate "Microsoft Excel" 'if sure only one instance
    or
    AppActivate Me.Caption ' in a userform

    Regards,
    Peter T

    "riva91" <[email protected]> wrote in message
    news:[email protected]...
    > I've been exploring alot of threads about this subject but haven't
    > found the right solution yet.
    >
    > My problem is that i have an excel sheet with a vba form uploaded on
    > our intranet. When a user downloads this file and immediately opens it,
    > it wil open the form through the workbook_open event.
    > No problem so far.
    > But when this user has already an instance of excel running the
    > userform opens on the background in this instance and is not always in
    > focus.
    >
    > What i want is to open this form in a new instance of excel if excel
    > is already running. I found a function that tests if excel is running.
    > But how can i control this workbook being opened in a new instance?
    > When i use the workbook_open event the choice has already been made for
    > me.
    >
    > Anyone a good idea?
    >
    > This is in dummy code what i want
    >
    > If fIsAppRunning("Excel") Then
    > Set objXL = CreateObject("Excel.Application")
    > frmEAED.Show ' to open this form in the objXL instance
    >
    >
    >
    > Regards,
    >
    > Bert Nijkoops
    >




+ 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