Activate an Excel file (open) in VBA without knowing its name.
Solved
filou3556
Posted messages
12
Status
Member
-
Jojo -
Jojo -
Hello,
For professional needs, I need to access an open Excel file via VBA. The problem is that this file doesn’t always have the same name. For example, it can be named TOTO, or TOTO(1) or TOTO(2).............
The proposed solution that I can't seem to implement would allow the macro to let me choose to activate it manually
Configuration: Windows Vista / Firefox 17.0
For professional needs, I need to access an open Excel file via VBA. The problem is that this file doesn’t always have the same name. For example, it can be named TOTO, or TOTO(1) or TOTO(2).............
The proposed solution that I can't seem to implement would allow the macro to let me choose to activate it manually
Configuration: Windows Vista / Firefox 17.0
4 answers
-
Hello,
Here's a proposal to adapt to your code:Sub test() Dim wb As Workbook, ok As Boolean For Each wb In Workbooks If Left(wb.Name, 4) = "toto" Then wb.Activate ok = True End If If ok Then Exit For Next wb If ok Then ' continuation of the process Else MsgBox "Toto file not found open" End If End Sub
Of course, it only works if your files are open in the same Excel session (same window).
Activates the first open file encountered starting with "toto". Case sensitivity counts.
Eric
--
In addition to the thank you (yes, it is done !!!), remember to mark as resolved when applicable (at the top next to your title).
Thank you