+ Reply to Thread
Results 1 to 4 of 4

Primary workbook is hidden when name of hidden workbook changes

Hybrid View

  1. #1
    Registered User
    Join Date
    04-28-2010
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Primary workbook is hidden when name of hidden workbook changes

    Hi,

    I have a file PQR.xlsm. When it opens, I want 'ABC.xlsx' and 'Std XYZ.xls', which are saved on a shared drive,to open as well, but remain hidden from view. This is because I have some vba code that does vlookup in PQR based on values in ABC and XYZ. So when I open PQR, all 3 workbooks open, but only PQR is visible.When PQR is closed, I want ABC and XYZ to close without save prompt. I managed to put this code together(after going thru some forums) that does what I want. However, last evening 'Std XYZ.xls' was changed to 'XYZ.xlsx'. When I tried opening PQR, all 3 were hidden. I went into vba and updated 'Std XYZ.xls' to 'XYZ.xlsx', but it wouldnt work. Can someone help me figure out why that is?

    When I have ActiveWorkbook.Windows(1).Visible = False, what is windows(1)?
    Is there a windows 2, 3 etc?

    Below is the code pasted in the 'ThisWorkbook' Excel Objects.

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Workbooks("ABC.xlsx").Saved = True
    Workbooks("XYZ.xlsx").Saved = True
    End Sub
    
    Private Sub Workbook_WindowActivate(ByVal Wn As Window)
    Dim wBook As Workbook
    Dim wBook1 As Workbook
                    
        On Error Resume Next
        Set wBook = Workbooks("ABC.xlsx")
        Set wBook1 = Workbooks("XYZ.xlsx")
         
        If wBook Is Nothing Then
            ChDir "T:\"
            Set wBook = Workbooks.Open(Filename:="\\DM0001.ABC.xlsx", ReadOnly:=True)
            ActiveWorkbook.Windows(1).Visible = False
        Else
        If wBook1 Is Nothing Then
        Set wBook1 = Workbooks.Open(Filename:="\\DM0001.XYZ.xlsx", ReadOnly:=True)
       ActiveWorkbook.Windows(1).Visible = False
         End If
         End If
          ThisWorkbook.Activate
            Worksheets("Instructions").Select
             
       
    End Sub
    Last edited by excel_vb; 05-02-2010 at 07:51 PM. Reason: Change subject line

  2. #2
    Registered User
    Join Date
    04-28-2010
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Hidden Workbook woes

    Hi,
    I was wondering if anyone had a reply for me.

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Hidden Workbook woes

    I was wondering if you had taken the time whilst waiting to read the Form Rules.

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    04-28-2010
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Primary workbook is hidden when name of hidden workbook changes

    Thanks for letting me know.
    I've tried my best to put my problem in 1 sentence. Please feel free to change it if there is a better way to convey my problem.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1