Message box of all hidden workbooks

kojak27

New Member
Joined
Sep 8, 2022
Messages
6
Office Version
  1. 2016
Platform
  1. Windows
I am using this code to Display a message of all open workbooks.

Sub LIST_OPEN_WORKBOOK_MESSAGE()
Dim a, i&, fn$, prefix$
ReDim a(1 To Workbooks.Count)

prefix = "report to excel."
For i = 1 To Workbooks.Count
a(i) = Workbooks(i).Name
If Left(a(i), Len(prefix)) = prefix Then fn = a(i)
Next i
MsgBox Join(a, vbLf)
If fn <> "" Then MsgBox fn
End Sub

How do I modify the code to Display a list of just the open HIDDEN workbooks?
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Welcome to the MrExcel forum. Please accept my warmest greetings and sincere hope that all is well.

Try:

VBA Code:
Sub LIST_hidden_WORKBOOK_MESSAGE()
  Dim a, i&, fn$, prefix$
  ReDim a(1 To Workbooks.Count)
  
  prefix = "report to excel."
  For i = 1 To Workbooks.Count
    If Application.Windows(i).Visible = False Then
      a(i) = Workbooks(i).Name
      If Left(a(i), Len(prefix)) = prefix Then fn = a(i)
    End If
  Next i
  MsgBox Join(a, vbLf)
  If fn <> "" Then MsgBox fn
End Sub
 
Upvote 0
I tried this and it still lists ALL of the open workbooks and not just the hidden ones.
 
Upvote 0
I tried this and it still lists ALL of the open workbooks and not just the hidden ones.
Try:
VBA Code:
Sub ListOpenHiddenWBs()
Dim Wb As Workbook, Ct As Long, Lst As String
For Each Wb In Workbooks
    If Not Windows(Wb.Name).Visible Then
        Ct = Ct + 1
        Lst = Lst & vbNewLine & Wb.Name
    End If
Next Wb
If Ct > 0 Then
    MsgBox "There are " & Ct & " hidden workbooks open:" & vbNewLine & Lst
Else
    MsgBox "There are no hidden workbooks open"
End If
End Sub
 
Upvote 0
Solution
Try:
VBA Code:
Sub ListOpenHiddenWBs()
Dim Wb As Workbook, Ct As Long, Lst As String
For Each Wb In Workbooks
    If Not Windows(Wb.Name).Visible Then
        Ct = Ct + 1
        Lst = Lst & vbNewLine & Wb.Name
    End If
Next Wb
If Ct > 0 Then
    MsgBox "There are " & Ct & " hidden workbooks open:" & vbNewLine & Lst
Else
    MsgBox "There are no hidden workbooks open"
End If
End Sub
Thanks, this worked perfectly.
 
Upvote 0
Try:

VBA Code:
Sub LIST_hidden_WORKBOOK_MESSAGE()
  Dim a, i&, fn$, prefix$, s
  ReDim a(1 To Workbooks.Count)
  
  prefix = "report to excel."
  For i = 1 To Workbooks.Count
    s = Workbooks(i).Name
    If Application.Windows(s).Visible = False Then
      a(i) = s
      If Left(a(i), Len(prefix)) = prefix Then fn = a(i)
    End If
  Next i
  MsgBox Join(a, vbLf)
  If fn <> "" Then MsgBox fn
End Sub
 
Upvote 0
Try:

VBA Code:
Sub LIST_hidden_WORKBOOK_MESSAGE()
  Dim a, i&, fn$, prefix$, s
  ReDim a(1 To Workbooks.Count)
 
  prefix = "report to excel."
  For i = 1 To Workbooks.Count
    s = Workbooks(i).Name
    If Application.Windows(s).Visible = False Then
      a(i) = s
      If Left(a(i), Len(prefix)) = prefix Then fn = a(i)
    End If
  Next i
  MsgBox Join(a, vbLf)
  If fn <> "" Then MsgBox fn
End Sub
That did the trick. Thanks.
 
Upvote 0

Forum statistics

Threads
1,215,072
Messages
6,122,966
Members
449,094
Latest member
Anshu121

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top