sspatriots
Well-known Member
- Joined
- Nov 22, 2011
- Messages
- 585
- Office Version
- 365
- Platform
- Windows
Hi,
My "Workbook_Open" event calls the code below when I open the workbook. This code in turn will open another workbook temporarily (just long enough to copy some information from it) and then closes it again. I need to be able have the code first check to see if the referenced file is already open when this code is initialized, because if it is I don't want my code to close the reference workbook at the end. I hope this makes sense. Not sure how else to explain this.
Thanks, SS
My "Workbook_Open" event calls the code below when I open the workbook. This code in turn will open another workbook temporarily (just long enough to copy some information from it) and then closes it again. I need to be able have the code first check to see if the referenced file is already open when this code is initialized, because if it is I don't want my code to close the reference workbook at the end. I hope this makes sense. Not sure how else to explain this.
Thanks, SS
VBA Code:
Sub Refresh_n_ResizeAllPOTables()
Dim wb1, wb2 As Workbook
Dim file_path1 As String
Set wb1 = ThisWorkbook
file_path1 = "H:\Jobs\SPS-PO Block History - DEM-030524-01.xlsm" 'Path to PO Block History - DEM.xlsm
Set wb2 = Workbooks.Open(Filename:=file_path1, ReadOnly:=True, IgnoreReadOnlyRecommended:=True) 'PO Block History - DEM.xlsm
'Does a lot of stuff here
wb2.Close SaveChanges:=False
End Sub