View Full Version : Unhide a Hidden Workbook
pcsparky
10-24-2009, 12:18 AM
I am trying to open a workbook in Excel 2007 using: Workbooks.Open (fileName)
Because the workbook needs to be hidden, the code is unable to execute.
Is there any code that I can use to unhide the WB, execute my code, and then hide the WB again?
I have tried Windows(fileName).Hidden = True but get an error as .Hidden isn't an option.
Bob Phillips
10-24-2009, 01:08 AM
It is
Windows(filename).Visible
pcsparky
10-24-2009, 01:28 AM
I tried that but I get 'Runtime Error 9' 'Subscript out of Range' and the fileName is definitely the right file name.
macropod
10-24-2009, 01:30 AM
Hi pcsparky,
How are you hiding the workbook, such that it's code won't run?
One possible approach is:
Sub Demo()
Dim strBook As String
strBook = "Data.xls"
With Application
'Hide the wb
.Workbooks(strBook).Windows(1).Visible = False
'Disable Screen Updating, so the unhidden wb won't be seen
.ScreenUpdating = False
'UnHide the wb
.Workbooks(strBook).Windows(1).Visible = True
'
'Do stuff
'
'Hide the wb again
.Workbooks(strBook).Windows(1).Visible = False
'Re-enable Screen Updating
.ScreenUpdating = True
End With
End Sub
pcsparky
10-24-2009, 02:04 AM
Not sure if I've made myself clear. The file is hidden using the (right-click)Properties, selecting the Attribute as Hidden.
Strangely Excel will open the file if it is not hidden but placed inside a folder that is hidden. So if I can't get code to work I can use that work around.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.