Excel 2010 Document Inspector reports hidden sheets, not shown in VBA

Page 1 of 2 12 LastLast

  1. Posts : 279
    Win 10 Pro 21H2 (OS Build 19045.3636)
       #1

    Excel 2010 Document Inspector reports hidden sheets, not shown in VBA


    I have a worksheet with 14 tabs along the bottom. I've had the worksheet for many years - creation date is 16 November 1997 -and it's evolved over time to be more and more useful. Obviously been through many versions of Excel. It has several user functions and VBA procedures.

    I'm currently running Excel 2010 and, out of curiosity, decided to run Document Inspector and see what it reported.

    All the messages, except one, was what I expected. The exception was that it reported 2 hidden sheets.

    I can't what it's referring to. The VBA list of Objects lists the expected 14 worksheets.

    I could, having made a copy, let Inspector remove the hidden sheets it's found, but I rather know what they are beforehand.

    Any thoughts on how to progress this? Of course it may be a bug in Excel, it may be something left over from previous versions of Excel.
      My Computers


  2. Posts : 16,950
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #2

    Right-click on the name tab of any sheet. If you have any hidden sheets then Unhide ... will be enabled [it is otherwise greyed out].

    Denis
      My Computer


  3. Posts : 279
    Win 10 Pro 21H2 (OS Build 19045.3636)
    Thread Starter
       #3

    Unhide is greyed out. I guess Document Inspector is somehow mis-reporting.
      My Computers


  4. Posts : 16,950
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #4

    If you have set a sheet's properties to xlVeryHidden then it will not enable the Hide ... entry but it will get reported by Document inspector.

    But I do not understand why it does not appear in your VBA sheet lister, which is assume is along the lines of
    Code:
    Sub ListSheets()
    Set NewSheet = Sheets.Add(Type:=xlWorksheet)
    For i = 1 To Sheets.Count
        NewSheet.Cells(i, 1).Value = Sheets(i).Name
    Next i
    End Sub

    In any case, you could make even xlVeryHidden sheets visible by running
    Code:
    Sub UnhideSheets()
    For Each Fred In Sheets
     Fred.Visible = True
    Next Fred
    End Sub
    and this will allow you to check what is in them then delete them manually if you want to.

    Denis
      My Computer


  5. Posts : 279
    Win 10 Pro 21H2 (OS Build 19045.3636)
    Thread Starter
       #5

    Here's the list of Objects shown in the VB Project.

    Attachment 241710

    So I then ran your List Sheets VB and it led me to what appears to be the issue.

    Your List Sheets Sub created a new sheet and listed all the sheets, including the new one and the VB Procedures and Functions. That set me wondering.

    So, working on a copy of the XLS, I ran Document Inspector (DI), Hidden Worksheets only, and let it delete those hidden worksheets. And, as I'd wondered, my macros and functions didn't work, they weren't there, DI had deleted them.

    So what appears to be the case is that for this workbook at least, DI sees the VB Procedures and Functions items shown in the VB Object List as hidden worksheets, and so deletes them.

    I've run DI on other macro-enable spreadsheets but they just have Module 1 containing the macros and are not seen by DI as hidden sheets.

    All rather interesting.
      My Computers


  6. Posts : 16,950
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #6

    I do not understand what has caused this situation. I have never seen a VBA module treated as a worksheet.

    It would be interesting to make another copy of the original to see what the macro ReportSheetVisibility does [see below].

    Here are the same VBA procedures again plus some others that I have been playing with while thinking about this situation

    Code:
    Sub VeryHiddenTest()
    ' Creates a new worksheet, sets it to xlVeryHidden and writes some random values in some cells
    ' xlVeryHidden sheets do not enable the Unhide ... control in the sheets tab context manu
    ' but do get reported by the Document inspector
    ' - the only way to make a xlVeryHidden sheet visible again is by setting this property to True (the user cannot make the object visible through the UI).
    Set NewSheet = Worksheets.Add
    NewSheet.Visible = xlVeryHidden
    NewSheet.Range("A1:D4").Formula = "=RAND()"
    End Sub
    
    Sub ListSheets()
    ' Creates a new sheet for logging then lists all sheets including hidden and xlVeryHidden ones in it
    Set NewSheet = Sheets.Add(Type:=xlWorksheet)
    For i = 1 To Sheets.Count
        NewSheet.Cells(i, 1).Value = Sheets(i).Name
    Next i
    End Sub
    
    Sub UnhideSheets()
    ' Unhides all sheets including xlVeryHidden ones
    For Each Fred In Sheets
     Fred.Visible = True
    Next Fred
    End Sub
    
    Sub ReportSheetVisibility()
    ' Report sheet visibility
    ' 0 is hidden
    ' -1 means visible
    ' 2 means xlVeryHidden
    For Each Fred In Sheets
     MsgBox "Sheet name " & Fred.Name & " Sheet visibility " & Fred.Visible
    Next Fred
    End Sub
    
    Sub UnhideVeryHiddenSheet()
    ' Unhides all xlVeryHidden sheets but not xlHidden ones
    For Each Fred In Sheets
     If Fred.Visible = 2 Then Fred.Visible = True
    Next Fred
    End Sub

    Denis
      My Computer


  7. Posts : 16,950
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #7

    Just a wild shot in the dark ...

    Didn't macros get recorded in worksheets before Excel switched to VBA?
    - I can't think how far back this was. Possibly Excel 4 in the early 1990s.
    - Of course, this would make no sense at all if your workbook had been created since, say, Excel 2007.

    If your workbook is older than that I'd suggest
    1 Create a new blank one then, with both open at once, use the sheet tab Move or copy ... to copy each sheet to the new blank workbook.
    2 In the VBEditor of the new workbook, create two new modules [Functions, Procedures] and then just copy the code text across from one to the other.
    3 In the VBEditor window of the old one, in the Microsoft Excel objects list select each sheet in turn {including ThisWorkbook} then right-click and select View code. If there is anything in any of them, copy it to the same place in the new workbook.
    Excel 2010 Document Inspector reports hidden sheets, not shown in VBA-vblist.jpg


    Denis
      My Computer


  8. Posts : 279
    Win 10 Pro 21H2 (OS Build 19045.3636)
    Thread Starter
       #8

    Will investigate later, about to go out.

    I think you may well be right about where Excel used to store macros. As I said in the first post the workbook creation date is shown as 1997. I know I used Office 97, probably earlier. I recall early Office versions were on 24(?) specially formatted floppy discs.

    - - - Updated - - -

    Created a new workbook and copied everything over. Ran DI and lo-and-behold no hidden sheets.

    Clearly an Excel 4.0 hangover. The copy to new workbook was very straightforward except for one user function which kept a reference to the old workbook file name, easily fixed though.

    Thank you.

    I was more intrigued than concerned about those 2 hidden sheets. Thank you for all your efforts and help.
      My Computers


  9. Posts : 16,950
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #9

    Just for the hell of it, run that UnhideSheets macro on another copy of that old one to see what it makes visible?

    Denis
      My Computer


  10. Posts : 279
    Win 10 Pro 21H2 (OS Build 19045.3636)
    Thread Starter
       #10

    I should have realised earlier when I ran your original code that the Functions & Procedures appearing in the list of sheets meant that they were some sort of sheet. It hadn't registered with me at the time.

    Running your later code and ReportSheetVisibility showed the Functions and Procedures to be VeryHidden.

    So all down to a hangover from Excel 4.0 and Macro Sheets. I'd really forgotten all about them.

    Thank you.

    Tony
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 07:22.
Find Us




Windows 10 Forums