Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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
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
how do i find out what data is hidden i excel dan cassidy Excel Worksheet Functions 1 March 26th 10 06:55 PM
How to find/replace all of the names of files in EXCEL workbook. Peter Multach Excel Discussion (Misc queries) 2 March 5th 07 02:52 PM
How can I find/unhide hidden excel sheet tabs on a worksheet? magician Excel Worksheet Functions 1 May 2nd 06 11:13 AM
How to find hidden names on an Excel worksheet ? Jon Sipworth Excel Worksheet Functions 2 December 13th 05 06:16 PM
Excel Workbook Hidden Problem GIScoobe Excel Programming 2 January 6th 05 01:15 AM


All times are GMT +1. The time now is 08:26 PM.

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

About Us

"It's about Microsoft Excel"