Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find Excel files that have hidden workbook
I am pretty new to coding in VB.NET. I wanted to write a code to search
through a list of Excel files and find those files that have a hidden workbook. I tried to capture the value of mExcelObj.ActiveWindow.Visible into a string and check if it is true or false, based on which I could identify whether the Excel file has a hidden workbook or not. Any guidance would be appreciated. Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find Excel files that have hidden workbook
An XL file IS a workbook.
For me, outside of XL (in the OS/File System etc) it is a file, whilst when opened in XL it is a workbook. There can only be 1 workbook in a file. It can however have multiple Worksheets. Assuming you are referring to whether the WB is hidden when opened (the default for Personal.xls), try this VBA. Private Sub CommandButton1_Click() Dim FileNames() As String Dim i As Long Dim WB As Workbook Dim RetVal As Boolean 'Fill the values from list 'FileNames() = ??? For i = LBound(FileNames) To UBound(FileNames) Set WB = Workbooks.Open(FileNames(i)) RetVal = IsWBHidden(WB) 'Save the result somewhere WB.Close False Next End Sub Private Function IsWBHidden(WB As Workbook) As Boolean Dim i As Long IsWBHidden = True With WB.Windows For i = 1 To .Count If .Item(i).Visible = True Then IsWBHidden = False Exit Function End If Next End With End Function NickHK "sparrow" wrote in message oups.com... I am pretty new to coding in VB.NET. I wanted to write a code to search through a list of Excel files and find those files that have a hidden workbook. I tried to capture the value of mExcelObj.ActiveWindow.Visible into a string and check if it is true or false, based on which I could identify whether the Excel file has a hidden workbook or not. Any guidance would be appreciated. Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Find Excel files that have hidden workbook
Thank you so much. It worked really well. Thanks once again for your
time. NickHK wrote: An XL file IS a workbook. For me, outside of XL (in the OS/File System etc) it is a file, whilst when opened in XL it is a workbook. There can only be 1 workbook in a file. It can however have multiple Worksheets. Assuming you are referring to whether the WB is hidden when opened (the default for Personal.xls), try this VBA. Private Sub CommandButton1_Click() Dim FileNames() As String Dim i As Long Dim WB As Workbook Dim RetVal As Boolean 'Fill the values from list 'FileNames() = ??? For i = LBound(FileNames) To UBound(FileNames) Set WB = Workbooks.Open(FileNames(i)) RetVal = IsWBHidden(WB) 'Save the result somewhere WB.Close False Next End Sub Private Function IsWBHidden(WB As Workbook) As Boolean Dim i As Long IsWBHidden = True With WB.Windows For i = 1 To .Count If .Item(i).Visible = True Then IsWBHidden = False Exit Function End If Next End With End Function NickHK "sparrow" wrote in message oups.com... I am pretty new to coding in VB.NET. I wanted to write a code to search through a list of Excel files and find those files that have a hidden workbook. I tried to capture the value of mExcelObj.ActiveWindow.Visible into a string and check if it is true or false, based on which I could identify whether the Excel file has a hidden workbook or not. Any guidance would be appreciated. Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how do i find out what data is hidden i excel | Excel Worksheet Functions | |||
How to find/replace all of the names of files in EXCEL workbook. | Excel Discussion (Misc queries) | |||
How can I find/unhide hidden excel sheet tabs on a worksheet? | Excel Worksheet Functions | |||
How to find hidden names on an Excel worksheet ? | Excel Worksheet Functions | |||
Excel Workbook Hidden Problem | Excel Programming |