Hi,
I am having an issue with the following code. The wb2 is not recognising the 2nd workbook (or file) i have open. As far as the code is concerned, wb and wb2 are the same file!!
As far as wb is concerned it is the current file that is open. the code is then to go and open the second file (being PAWEEK7.xls) and it should then recognise this as wb2...
Any ideas on how to fix this ?
I am having an issue with the following code. The wb2 is not recognising the 2nd workbook (or file) i have open. As far as the code is concerned, wb and wb2 are the same file!!
Code:
Private Sub Workbook_Open()
Dim WB As Workbook
Dim WB2 As Workbook
Dim JunkData As New DataObject ' Declare Variable to clear out clipboard
Dim newfile As String
Application.DisplayAlerts = False
Set WB = Workbooks(Dir(ActiveWorkbook.FullName))
Debug.Print WB.FullName
Sheets("Menu").Select
Range("A1").Select
Workbooks.Open FileName:="C:\temp\PAWeek7.xls", ReadOnly:=True
Set WB2 = Workbooks(Dir(ActiveWorkbook.FullName))
Debug.Print WB2.FullName
WB2.Activate
As far as wb is concerned it is the current file that is open. the code is then to go and open the second file (being PAWEEK7.xls) and it should then recognise this as wb2...
Any ideas on how to fix this ?