Thread: [Solved] list of Opened excel files
View Single Post
 
Old 02-21-2018, 03:40 PM
goose0701 goose0701 is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Feb 2018
Posts: 4
goose0701 is on a distinguished road
Default

Hello All!

I know this one is solved, but I didn't want to start a whole new thread for the same issue (pretty close).

I used the code above with a tweak to populate a listbox, but it is only picking up 1 open excel file. it is not doing each.

here is my code:
Code:
Public Sub UserForm_Initialize()
    
Dim ObjXL As Object, xlWkBk, StrWkBks As String

' Test to see if there is a copy of Microsoft Excel already running.
On Error Resume Next
Set ObjXL = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
  filelist.AddItem ("No Excel Files are open (Excel is not running)")
  Exit Sub
End If
For Each xlWkBk In ObjXL.Workbooks
filelist.AddItem xlWkBk.Name
Next xlWkBk

Set ObjXL = Nothing
    
End Sub
does anyone know where I am going wrong on this one?
Reply With Quote