PDA

View Full Version : Solved: Application.Visible = False



vzachin
09-01-2011, 10:34 AM
hi,

i have a macro that i want to run but keep the workbook hidden, so as i don't close it by accident.
so i added
Application.Visible = False
.

this works to hide the workbook however when i open another instance of Excel, my original workbook is restored. is there a way around this? any suggestions?

thanks
zach

Kenneth Hobs
09-01-2011, 10:47 AM
ActiveWindow.Visible = False

vzachin
09-01-2011, 05:13 PM
hi Kenneth,
i will give that a try.

thanks
zach

vzachin
09-02-2011, 08:19 AM
kenneth,

after applying


ActiveWindow.Visible = False

if i have another Excel Workbook opened,
how do i code it to


ActiveWindow.Visible =True


how do i code it to bring focus back to the original workbook and unhide the sheet?

thanks again
zach

Kenneth Hobs
09-02-2011, 09:43 AM
Untested:Dim wb as Workbook
Set wb=Workbooks("TheNameHere.xls")
wb.Visible =True
wb.activate
wb.Sheet1.Visible = True

You could use this this kind of thing to see if it is open or not:

Sub Test_IsWorkbookOPen()
MsgBox IsWorkbookOpen("Personal.xls"), , "Personal.xls Open?"
MsgBox IsWorkbookOpen("Personal.xlsb"), , "Personal.xlsb Open?"
End Sub

Function IsWorkbookOpen(stName As String) As Boolean
Dim Wkb As Workbook
On Error Resume Next ' In Case it isn't Open
Set Wkb = Workbooks(stName)
If Not Wkb Is Nothing Then IsWorkbookOpen = True
'Boolean Function assumed To be False unless Set To True
End Function

vzachin
09-02-2011, 11:21 AM
hi Kenneth

Dim wb As Workbook
Set wb = Workbooks("Hide Workbook Test.xls")
wb.Visible = True 'Getting runtimme error 438
wb.Activate
wb.Sheet1.Visible = True

thanks for looking at this
zach

Kenneth Hobs
09-02-2011, 11:35 AM
Have it your way with Windows...

Sub t()
Dim wb As Workbook
Set wb = Workbooks(ThisWorkbook.Name)
wb.Worksheets(Sheet1.Name).Visible = xlSheetVeryHidden
Windows(wb.Name).Visible = False
Windows(wb.Name).Visible = True
wb.Activate
wb.Worksheets(Sheet1.Name).Visible = xlSheetVisible
End Sub

vzachin
09-06-2011, 10:23 AM
thanks kenneth

zach