Results 1 to 3 of 3

Thread: Hiding Workbook with other workbook open

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2012
    Posts
    8

    Hiding Workbook with other workbook open

    Hi All,

    What I basically have is 2 workbooks the first one opens when the user selects to open it and the second one opens when the first workbook is open (In workbook open).

    I would like to hide up the 2nd workbook - but the first workbook is constantly referencing the second workbook for information.

    Does anyone know how would be best to do this?

    Thanks in Advance

  2. #2
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,574

    Re: Hiding Workbook with other workbook open

    create a workbook object, then hide it. you can still "get at it" when hidden, like so:

    Code:
    Dim wb2 As Workbook     
    
    Private Sub Workbook_Open()   'opening "workbook1"
        Dim myDir As String
        Dim myFile As String
        
        myDir = ActiveWorkbook.Path
        myFile = myDir & "\wb2.xlsx"
        Set wb2 = Workbooks.Open(myFile)
        wb2.Windows(1).Visible = False
        MsgBox wb2.Worksheets(1).Range("a1").Value  'to show you can access the hidden workbook object
    End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2012
    Posts
    8

    Re: Hiding Workbook with other workbook open

    Quote Originally Posted by vbfbryce View Post
    create a workbook object, then hide it. you can still "get at it" when hidden, like so:

    Code:
    Dim wb2 As Workbook     
    
    Private Sub Workbook_Open()   'opening "workbook1"
        Dim myDir As String
        Dim myFile As String
        
        myDir = ActiveWorkbook.Path
        myFile = myDir & "\wb2.xlsx"
        Set wb2 = Workbooks.Open(myFile)
        wb2.Windows(1).Visible = False
        MsgBox wb2.Worksheets(1).Range("a1").Value  'to show you can access the hidden workbook object
    End Sub
    Thanks it worked great!

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width