Results 1 to 2 of 2

Thread: [RESOLVED] Picking up on running Excel application

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    Belgium
    Posts
    68

    Resolved [RESOLVED] Picking up on running Excel application

    I want to check if Excel is running. If that is the case I want to check each workbook if there are 4 sheets with the names I specify and when true I want to access those sheets.

    Is this possible?
    I can't find a way to interact with a running Excel.

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Picking up on running Excel application

    VB Code:
    1. Dim XLS As Object
    2. Private Function GetExcel() As Boolean
    3.     On Error GoTo NotRunning
    4.     Set XLS = GetObject(, "Excel.Application")
    5.     GetExcel = True
    6.     Exit Function
    7. NotRunning:
    8.     Set XLS = Nothing
    9.     GetExcel = False
    10. End Function
    11.  
    12. Private Sub Form_Load()
    13.     If GetExcel Then
    14.         For x = 1 To XLS.Workbooks.Count
    15.             For i = 1 To XLS.Workbooks(x).sheets.Count
    16.                 Debug.Print XLS.Workbooks(x).Name & ": " & XLS.Workbooks(x).sheets(i).Name
    17.             Next
    18.         Next
    19.     Else
    20.         Debug.Print "Excel is not running"
    21.     End If
    22. End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

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