none
VBA - Open Workbook Same Instance - But Hidden RRS feed

  • Question

  • Hi friends,

     

    I am trying to open another workbook.

     

    I would like to open it hidden in the same Instance.

    This doesn’t work, and i tried many others as well

     

     

    Private Sub Workbook_Open()

    Application.ActiveWorkbook.Visible = false

    End Sub

     

    Object doesn’t support this method

     

     

    Any ideas?


    Cheers Dan :)


    • Edited by Dan_CS Thursday, February 2, 2017 4:53 PM
    Thursday, February 2, 2017 4:52 PM

Answers

  • Why do all beginners always want to do strange things? :-)

    Andreas.

    Sub Test()
      Dim Wb As Workbook
      'Screen off
      Application.ScreenUpdating = False
      'Open the file
      Set Wb = Workbooks.Open("Z:\File.xlsx")
      'Hide it
      Wb.Windows(1).Visible = False
    End Sub


    • Marked as answer by Dan_CS Thursday, February 9, 2017 1:34 AM
    Thursday, February 2, 2017 5:24 PM

All replies

  • Why do all beginners always want to do strange things? :-)

    Andreas.

    Sub Test()
      Dim Wb As Workbook
      'Screen off
      Application.ScreenUpdating = False
      'Open the file
      Set Wb = Workbooks.Open("Z:\File.xlsx")
      'Hide it
      Wb.Windows(1).Visible = False
    End Sub


    • Marked as answer by Dan_CS Thursday, February 9, 2017 1:34 AM
    Thursday, February 2, 2017 5:24 PM
  • Hi Andreas,

     

    I am by nature very ocd about having things listed and organised :)

     

    Too many windows confuse me and make me do the wrong thing.

     

    Just a quick one

     

    Does this work for you

    Private Sub Workbook_Open()
    
    HiddenWorkbook
    
    End Sub
    
    Sub HiddenWorkbook()
      Dim Wb As Workbook
      'Screen off
      Application.ScreenUpdating = False
      'Open the file
      Set Wb = ThisWorkbook
      'Hide it
      Wb.Windows(1).Visible = False
    End Sub
    
    

    That way i can access the modules in project explorer without having 5 workbooks open if i do this


    Cheers Dan :)

    Thursday, February 2, 2017 5:38 PM
  • Hello Andreas,

     

    This worked as you showed, I probably eventually figure out the other one, when I can get round to it :)


    Cheers Dan :)

    Thursday, February 9, 2017 1:34 AM