+ Reply to Thread
Results 1 to 10 of 10

[SOLVED] How to keep an instance of Excel away from the user?

  1. #1
    RzB
    Guest

    [SOLVED] How to keep an instance of Excel away from the user?

    Using Office 2002/3 and DAO

    I have an Access application that creates a new
    spreadsheet basically using the code shown at the
    end of this post..

    While the spreadsheet is being created I present
    the user with a a simple form giving them
    feedback on the progress. I make sure they are
    unable to do anything else on my Access
    application while this is going on.

    It all works really well but there is one problem...

    If the user opens Excel while the process is
    executing and then closes Excel, then my Excel object
    in the access code dissapears. A bit fatal.

    Is there some way I can open the an instance of
    Excel and stop others from using the same instance.

    Or is there some better way ?

    Many thanks,
    Roy

    --------------------------------------------
    Private m_objXlApp As Excel.Application
    Private m_objXlWkb As Excel.Workbook
    Private m_objXlSht As Excel.Worksheet
    Private m_rngCurrentRange As Excel.Range

    Set m_objXlApp = New Excel.Application
    m_objXlApp.Visible = False
    Set m_objXlWkb = m_objXlApp.Workbooks.Add
    Set m_objXlSht = m_objXlWkb.Worksheets("Sheet1")
    Set m_rngCurrentRange = m_objXlSht.Range(ProgramTopLeftCell)
    .......
    m_rngCurrentRange.Offset(intRowPosCount, conZSize) = whatever

    etc...all sorts of sheet creation, cell
    filling and formatting going on here..
    etc...
    ......
    Set m_rngCurrentRange = Nothing
    Set m_objXlSht = Nothing

    m_objXlWkb.Close
    Set m_objXlWkb = Nothing

    m_objXlApp.Quit
    Set m_objXlApp = Nothing
    ------------------------------------------



  2. #2
    NickHK
    Guest

    Re: How to keep an instance of Excel away from the user?

    Roy,
    You mean that the user interacts with your m_objXlApp instance of Excel ?
    If they open/close another instance of Excel, it should not affect your
    hidden instance.

    NickHK

    "RzB" <Please@Reply.To.Newsgroup> wrote in message
    news:ehVtWAkoFHA.708@TK2MSFTNGP09.phx.gbl...
    > Using Office 2002/3 and DAO
    >
    > I have an Access application that creates a new
    > spreadsheet basically using the code shown at the
    > end of this post..
    >
    > While the spreadsheet is being created I present
    > the user with a a simple form giving them
    > feedback on the progress. I make sure they are
    > unable to do anything else on my Access
    > application while this is going on.
    >
    > It all works really well but there is one problem...
    >
    > If the user opens Excel while the process is
    > executing and then closes Excel, then my Excel object
    > in the access code dissapears. A bit fatal.
    >
    > Is there some way I can open the an instance of
    > Excel and stop others from using the same instance.
    >
    > Or is there some better way ?
    >
    > Many thanks,
    > Roy
    >
    > --------------------------------------------
    > Private m_objXlApp As Excel.Application
    > Private m_objXlWkb As Excel.Workbook
    > Private m_objXlSht As Excel.Worksheet
    > Private m_rngCurrentRange As Excel.Range
    >
    > Set m_objXlApp = New Excel.Application
    > m_objXlApp.Visible = False
    > Set m_objXlWkb = m_objXlApp.Workbooks.Add
    > Set m_objXlSht = m_objXlWkb.Worksheets("Sheet1")
    > Set m_rngCurrentRange = m_objXlSht.Range(ProgramTopLeftCell)
    > ......
    > m_rngCurrentRange.Offset(intRowPosCount, conZSize) = whatever
    >
    > etc...all sorts of sheet creation, cell
    > filling and formatting going on here..
    > etc...
    > .....
    > Set m_rngCurrentRange = Nothing
    > Set m_objXlSht = Nothing
    >
    > m_objXlWkb.Close
    > Set m_objXlWkb = Nothing
    >
    > m_objXlApp.Quit
    > Set m_objXlApp = Nothing
    > ------------------------------------------
    >
    >




  3. #3
    DM Unseen
    Guest

    Re: How to keep an instance of Excel away from the user?

    don't forget m_objXlApp.IgnoreRemoteRequests = True 'to prevent user to
    launch XL files through explorer
    and if your really paranoid also:
    m_objXlApp.Interactive = False

    DM Unseen


  4. #4
    RzB
    Guest

    Re: How to keep an instance of Excel away from the user?

    What I mean is ...

    I set my access code running and it's opened Excel, and is quietly creating
    sheets, filling in cells and doing some formatting. Lets call the file it
    has created is AAA.xls.
    This should all be out of sight of the user. All he can see is a small form
    running with a little activity showing how progress is going. He has no
    interaction with this process other than to watch it the progress in this
    form.

    Now - if the user opens Windows Explorer, while this is all going on, and
    double clicks on BBB.wks, Excel opens and he is able to see the BBB.wks in
    an Excel window. However if he were to look in command bar - Window he would
    see BBB.wks and AAA.wks referenced.

    If he now closes Excel he is asked if he wants to save AAA, and if he says
    yes the we have a problem. We probably have a problem if he says no as
    well...

    Am I doing something wrong ?

    Many thanks for your help,
    Roy




















  5. #5
    NickHK
    Guest

    Re: How to keep an instance of Excel away from the user?

    Roy,
    So you showing an Excel userform ?

    NickHK

    "RzB" <Please@Reply.To.Newsgroup> wrote in message
    news:euk0ONloFHA.1468@TK2MSFTNGP12.phx.gbl...
    > What I mean is ...
    >
    > I set my access code running and it's opened Excel, and is quietly

    creating
    > sheets, filling in cells and doing some formatting. Lets call the file it
    > has created is AAA.xls.
    > This should all be out of sight of the user. All he can see is a small

    form
    > running with a little activity showing how progress is going. He has no
    > interaction with this process other than to watch it the progress in this
    > form.
    >
    > Now - if the user opens Windows Explorer, while this is all going on, and
    > double clicks on BBB.wks, Excel opens and he is able to see the BBB.wks in
    > an Excel window. However if he were to look in command bar - Window he

    would
    > see BBB.wks and AAA.wks referenced.
    >
    > If he now closes Excel he is asked if he wants to save AAA, and if he says
    > yes the we have a problem. We probably have a problem if he says no as
    > well...
    >
    > Am I doing something wrong ?
    >
    > Many thanks for your help,
    > Roy
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >




  6. #6
    RzB
    Guest

    Re: How to keep an instance of Excel away from the user?

    No. Do I need to? I'm just trying to create an Excel
    spreadseheet from within Access.

    I don't think I need an Excel userform...There is no
    interaction needed from the user...

    Unless there is something here I don't understand...?

    Thanks,
    Roy

    "NickHK" <TungCheWah@Invalid.com> wrote in message
    news:eJkryZloFHA.3656@TK2MSFTNGP09.phx.gbl...
    > Roy,
    > So you showing an Excel userform ?
    >
    > NickHK
    >
    > "RzB" <Please@Reply.To.Newsgroup> wrote in message




  7. #7
    RzB
    Guest

    Re: How to keep an instance of Excel away from the user?

    Brilliant... That fixed it...

    Thank you very, very much...

    Roy

    "DM Unseen" <dm.unseen@gmail.com> wrote in message
    news:1124183930.704350.95740@o13g2000cwo.googlegroups.com...
    > don't forget m_objXlApp.IgnoreRemoteRequests = True 'to prevent user to
    > launch XL files through explorer
    > and if your really paranoid also:
    > m_objXlApp.Interactive = False
    >
    > DM Unseen
    >




  8. #8
    RzB
    Guest

    Re: How to keep an instance of Excel away from the user?

    Problem fixed by DM Unseen - see other post in this thread...

    m_objXlApp.IgnoreRemoteRequests = True

    fixed the problem...

    Roy



  9. #9
    RzB
    Guest

    Re: How to keep an instance of Excel away from the user?

    Hmmm....

    Since implementing this I seem to have a problem with Excel...

    If I double click on a xls file in windows explorer, excel
    burst into life but does not open the target file...

    It just sits there with no file loaded...

    Have I screwed something up ?

    Many thanks,
    Roy

    "RzB" <Please@Reply.To.Newsgroup> wrote in message
    news:%23Q3YsImoFHA.3316@TK2MSFTNGP14.phx.gbl...
    > Brilliant... That fixed it...
    >
    > Thank you very, very much...
    >
    > Roy
    >
    > "DM Unseen" <dm.unseen@gmail.com> wrote in message
    > news:1124183930.704350.95740@o13g2000cwo.googlegroups.com...
    >> don't forget m_objXlApp.IgnoreRemoteRequests = True 'to prevent user to
    >> launch XL files through explorer
    >> and if your really paranoid also:
    >> m_objXlApp.Interactive = False
    >>
    >> DM Unseen
    >>

    >
    >




  10. #10
    RzB
    Guest

    Re: How to keep an instance of Excel away from the user?

    Ok - just for information..

    Setting m_objXlApp.IgnoreRemoteRequests = True
    stays with excel when the application completes...

    What I have done now is to save the setting, then
    set is as above, then restore it to when my application
    completes.

    Roy

    "RzB" <Please@Reply.To.Newsgroup> wrote in message
    news:eBapECQpFHA.736@tk2msftngp13.phx.gbl...
    > Hmmm....
    >
    > Since implementing this I seem to have a problem with Excel...
    >
    > If I double click on a xls file in windows explorer, excel
    > burst into life but does not open the target file...
    >
    > It just sits there with no file loaded...
    >
    > Have I screwed something up ?
    >
    > Many thanks,
    > Roy
    >
    > "RzB" <Please@Reply.To.Newsgroup> wrote in message
    > news:%23Q3YsImoFHA.3316@TK2MSFTNGP14.phx.gbl...
    >> Brilliant... That fixed it...
    >>
    >> Thank you very, very much...
    >>
    >> Roy
    >>
    >> "DM Unseen" <dm.unseen@gmail.com> wrote in message
    >> news:1124183930.704350.95740@o13g2000cwo.googlegroups.com...
    >>> don't forget m_objXlApp.IgnoreRemoteRequests = True 'to prevent user to
    >>> launch XL files through explorer
    >>> and if your really paranoid also:
    >>> m_objXlApp.Interactive = False
    >>>
    >>> DM Unseen
    >>>

    >>
    >>

    >
    >




+ 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