Lifeseeker
Registered User.
- Local time
- Today, 14:24
- Joined
- Mar 18, 2011
- Messages
- 273
Hi there,
I have a set of code that helps me check whether or not excel workbooks are open. I'm actually running the code in access.
I'm getting an error on the line where I declare workbook.
Doesn't VBA recognize such declaration?
Any help or comment is appreciated.
I have a set of code that helps me check whether or not excel workbooks are open. I'm actually running the code in access.
Code:
Public Sub workbookopen()
'code to check if 4 sites are open
Dim location_Central As String
Dim location_East As String
Dim location_North As String
Dim location_South As String
Dim wbk_central As workbook
Dim wbk_north As workbook
Dim wbk_south As workbook
Dim wbk_east As workbook
location_Central = "C:\Central.xlsx"
location_East = "C:\East.xlsx"
location_North = "C:\North.xlsx"
location_South = "C:\South.xlsx"
Set wbk_central = Workbooks.Open(location_Central)
'Check to see if workbooks are currently open
If wbk_central.ReadOnly Then
ActiveWorkbook.Close
MsgBox "Cannot update the Central spreadsheet, someone currently using file. Please try again later."
Exit Sub
End If
Set wbk_north = Workbooks.Open(location_North)
If wbk_north.ReadOnly Then
ActiveWorkbook.Close
MsgBox "Cannot update the North spreadsheet, someone currently using file. Please try again later."
Exit Sub
End If
Set wbk_north = Workbooks.Open(location_South)
If wbk_north.ReadOnly Then
ActiveWorkbook.Close
MsgBox "Cannot update the South spreadsheet, someone currently using file. Please try again later."
Exit Sub
End If
Set wbk_east = Workbooks.Open(location_East)
If wbk_east.ReadOnly Then
ActiveWorkbook.Close
MsgBox "Cannot update the East spreadsheet, someone currently using file. Please try again later."
Exit Sub
End If
End Sub
I'm getting an error on the line where I declare workbook.
Doesn't VBA recognize such declaration?
Any help or comment is appreciated.