Consulting

Results 1 to 8 of 8

Thread: Solved: Application.Visible = False

  1. #1
    VBAX Tutor
    Joined
    Feb 2006
    Posts
    295
    Location

    Solved: Application.Visible = False

    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
    [vba]Application.Visible = False
    [/vba].

    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

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    [VBA]ActiveWindow.Visible = False[/VBA]

  3. #3
    VBAX Tutor
    Joined
    Feb 2006
    Posts
    295
    Location
    hi Kenneth,
    i will give that a try.

    thanks
    zach

  4. #4
    VBAX Tutor
    Joined
    Feb 2006
    Posts
    295
    Location
    kenneth,

    after applying
    [vba]
    ActiveWindow.Visible = False
    [/vba]
    if i have another Excel Workbook opened,
    how do i code it to
    [vba]
    ActiveWindow.Visible =True
    [/vba]
    how do i code it to bring focus back to the original workbook and unhide the sheet?

    thanks again
    zach

  5. #5
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Untested:[VBA]Dim wb as Workbook
    Set wb=Workbooks("TheNameHere.xls")
    wb.Visible =True
    wb.activate
    wb.Sheet1.Visible = True[/VBA]

    You could use this this kind of thing to see if it is open or not:
    [VBA]
    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[/VBA]

  6. #6
    VBAX Tutor
    Joined
    Feb 2006
    Posts
    295
    Location
    hi Kenneth

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

    thanks for looking at this
    zach

  7. #7
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Have it your way with Windows...

    [vba]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
    [/vba]

  8. #8
    VBAX Tutor
    Joined
    Feb 2006
    Posts
    295
    Location
    thanks kenneth

    zach

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •