List all open workbooks

Monsora83

Registered User.
Local time
Today, 06:43
Joined
May 16, 2011
Messages
41
Hi all, back again.

I'm trying to get a small sub to show all the currently open workbooks. I copied this excel code I found through google, is there a quick way to modify it to run with access, or maybe there is a snippet I couldn't find buried on this forum using the search function.

Code:
Private sub OpenWorkbooks()
 
Dim msg As String, wb As Workbook

For Each wb In Application.Workbooks
    msg = msg & wb.Name & vbLf
Next wb

MsgBox msg, , "Open Workbooks"
 
End Sub

Any help is appriciated.

Thanks
 
Access doesn't have workbooks. What do you want to get a list of in Access?
 
Access doesn't have workbooks. What do you want to get a list of in Access?

I am trying to get the access code to cycle through all the open currently open workbooks and return each name through a messagebox. Not to specificly generate a list, but to list each of them on at a time (or all at once) in a messagebox.
 
Right, the code you got from whereever you found it will not list all open Excel workbooks. It will list those workbooks that were opened via the current instance of Excel. If you opened a workbook via another instance it will not be part of the Workbooks.Count for the Excel application instance.

You will need to get the full path of all instances of Excel via command prompt or WMI to "hook" to Task Manager. Then from there you can determine which ones are open.

So your first step is to research the tasklist command in command prompt and WMI for Task Manager.
 

Users who are viewing this thread

Back
Top Bottom