Hello to all,
I have 2 Excel Workbooks (DataBase.xlsx and Program.xlsm)
DataBase.xlsx is a shared file located on a shared folder (Teams/Sharepoint). Program.xlsm is an Excel file located on user's PC.
Any User can insert and retrieve Data from the DataBase.xlsx.
I am using GetObject to open with an invisible way the DataBase.xlsx each time that a user wants to Add Or fetch Data.
The problem is that if the DataBase is already opened, the GetObject fails and returns an error : "File name or class name not found during Automation operation", but if it's already closed and I call GetObject there is no problem and the code works fine.
Also, if I place the DataBase.xlsx on a local folder (not the shared one), even if it's already opened I can still call the GetObject without any problem.
Is there anyway to solve this and to allow users to save and fetch data from an excel even if it's already opened by another one ?
Here is the part of my code where I am facing the problem :
I have 2 Excel Workbooks (DataBase.xlsx and Program.xlsm)
DataBase.xlsx is a shared file located on a shared folder (Teams/Sharepoint). Program.xlsm is an Excel file located on user's PC.
Any User can insert and retrieve Data from the DataBase.xlsx.
I am using GetObject to open with an invisible way the DataBase.xlsx each time that a user wants to Add Or fetch Data.
The problem is that if the DataBase is already opened, the GetObject fails and returns an error : "File name or class name not found during Automation operation", but if it's already closed and I call GetObject there is no problem and the code works fine.
Also, if I place the DataBase.xlsx on a local folder (not the shared one), even if it's already opened I can still call the GetObject without any problem.
Is there anyway to solve this and to allow users to save and fetch data from an excel even if it's already opened by another one ?
Here is the part of my code where I am facing the problem :
VBA Code:
Dim SharedDataBaseWb As Workbook
Dim SharedDataBaseWs As Worksheet
Dim sDataBaseFolder As String
Dim sFileName As String
Dim sFullFileName As String
sDataBaseFolder = Params.Range("ParamsDBFolder").Value2
sFileName = "DataBase.xlsx"
sFullFileName = sDataBaseFolder & sFileName
Set SharedDataBaseWb = GetObject(sFullFileName) 'At this line I am getting the error
Set SharedDataBaseWs = SharedDataBaseWb.Worksheets("RawData")
End If
With SharedDataBaseWs
'My code
End with