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
Bookmarks