Results 1 to 2 of 2

Thread: Excel Opens Multiple Times

  1. #1

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Question Excel Opens Multiple Times

    I open a spreadsheet I want to work with when my program loads using the code below. Each time i execute my code to perform some calculations on the spreadsheet a new instance of Excel is opened. How do i stop a new instance of Excel opening when I execute my code?

    Thanks.
    Code:
    Private Sub Form_Load()
    oXLApp.Workbooks.Open FileName:=App.Path & "" & "OSPREY.xls", Notify:=True 
    oXLApp.Sheets("LBOP-New Capital p.a" ).Select  
    End Sub

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343
    When you want to open excel, you will need to check that
    a) Excel is open - if not open it
    b) that the workbook you want is open - if not open it

    Then you can use the reference to the workbook (b) which will not reopen the workbook again.


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

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