+ Reply to Thread
Results 1 to 4 of 4

GetObject returning an error if the file is already open

  1. #1
    Registered User
    Join Date
    10-25-2022
    Location
    Paris, France
    MS-Off Ver
    Office 365 Desktop Version
    Posts
    2

    GetObject returning an error if the file is already open

    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 :

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: GetObject returning an error if the file is already open


    Hello,

    not on VBA side with GetObject - or check first if the workbook is already opened - as it well works when not on Sharepoint
    so Sharepoint seems to lock the opened workbook … What the IT says ?

  3. #3
    Registered User
    Join Date
    10-25-2022
    Location
    Paris, France
    MS-Off Ver
    Office 365 Desktop Version
    Posts
    2

    Re: GetObject returning an error if the file is already open

    Thanks Marc, I thought about making a kind of function to test if file is open by trapping the error and if it's open I will use something like

    Please Login or Register  to view this content.
    instead of GetObject.

    and if it's not open I use the GetObject

    I will try that tomorrow.

    Is there any function for that ? as long as I know, I have to make my own function based on error trapping right ?
    Last edited by JustGreat; 03-09-2023 at 10:20 PM.

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: GetObject returning an error if the file is already open


    Yes in case of a direct attempt but useless with a smart enough code just checking each name from the Workbooks collection …

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Open Excel Workbook with GetObject
    By EssoExplJoe in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-09-2017, 04:22 PM
  2. [SOLVED] Excel Hyperlink to open pdf- Error - "No program is registered to open this file
    By laxminarayana in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-27-2016, 10:03 AM
  3. [SOLVED] GetObject doesn't recognize file name
    By Pamelaann in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-18-2012, 03:37 PM
  4. error when use getobject()
    By darren1979 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 03-29-2010, 09:54 PM
  5. GetObject / Inputs from Text file
    By GrishaP in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-29-2006, 05:14 AM
  6. GetObject Error 429 - ActiveX control cannot create object
    By EAB1977 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-14-2006, 09:40 AM
  7. GetObject error 429
    By Brian Delaney in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-23-2005, 11:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1