Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Code to list concurrently open workbooks

Forgot to post the FileFromPath function:

Function FileFromPath(ByVal strFullPath As String, _
Optional bExtensionOff As Boolean) As String

Dim FPL As Long 'len of full path
Dim PLS As Long 'position of last slash
Dim pd As Long 'position of dot before exension
Dim strFile As String

On Error GoTo ERROROUT

FPL = Len(strFullPath)
PLS = InStrRev(strFullPath, "\", , vbBinaryCompare)
strFile = Right$(strFullPath, FPL - PLS)

If bExtensionOff = False Then
FileFromPath = strFile
Else
pd = InStr(1, strFile, ".", vbBinaryCompare)
FileFromPath = Left$(strFile, pd - 1)
End If

Exit Function
ERROROUT:

End Function


RBS


"RB Smissaert" wrote in message
...
The posted code will miss out on add-ins that are open, but not loaded as
an add-in.
This code will correct that:

Sub test2()

Dim i As Long
Dim oProject
Dim oWB As Workbook
Dim collWorkbooks As Collection

Set collWorkbooks = New Collection

On Error Resume Next

For Each oProject In Application.VBE.VBProjects
collWorkbooks.Add FileFromPath(oProject.Filename, False), _
FileFromPath(oProject.Filename, False)
Next oProject

For Each oWB In Application.Workbooks
collWorkbooks.Add FileFromPath(oWB.Name, False), _
FileFromPath(oWB.Name, False)
Next oWB

For i = 1 To collWorkbooks.Count
MsgBox collWorkbooks(i)
Next i

End Sub


RBS


"DaveO" wrote in message
...
That's what I was looking for, thanks!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
vba code to open workbooks Rebecca1 Excel Worksheet Functions 3 March 5th 08 05:15 PM
List of open workbooks anamarie30 Excel Programming 1 July 30th 07 02:32 PM
open two files with the same name concurrently joanne Excel Programming 2 April 15th 04 04:41 AM
Getting list of open workbooks [email protected] Excel Programming 7 November 26th 03 09:09 PM
List Open Workbooks in VBA Chip Pearson Excel Programming 1 November 17th 03 05:21 PM


All times are GMT +1. The time now is 04:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"