+ Reply to Thread
Results 1 to 13 of 13

Run-time Error on Method 'Open' of object '_Connection'

  1. #1
    Forum Contributor
    Join Date
    09-19-2017
    Location
    London
    MS-Off Ver
    2015
    Posts
    169

    Question Run-time Error on Method 'Open' of object '_Connection'

    Hi, all

    I have this one file that several users have to run. It can run from my end perfectly but not from other users' end (have tried with 2 users so far).

    This error has been prompted:
    Annotation 2020-11-11 154710.jpg

    And the line highlighted is at:
    Please Login or Register  to view this content.
    The tough part here is that this issue happens to some other people except me. With my limited experience, I'm not really sure how to debug this issue. Perhaps anyone who are used to this kind of error can give some insights?

    Thanks!

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,640

    Re: Run-time Error on Method 'Open' of object '_Connection'

    My first concept is that probably on your computer you have the reference to the ADO library and other users don't have it.

    Open VBA Editor (Alt+F11) and look into Tools->References

    You probably will see something like "Microsoft DAO 3.6 Object Library" with checkmark next to it. And other users probably don't have it checked.
    Best Regards,

    Kaper

  3. #3
    Forum Contributor
    Join Date
    09-19-2017
    Location
    London
    MS-Off Ver
    2015
    Posts
    169

    Re: Run-time Error on Method 'Open' of object '_Connection'

    Hi, Kaper

    I've compared the other users' References with mine, and we only ticked this:
    Annotation 2020-11-11 193049.jpg

    I did not tick the object library you mentioned but still manage to run the program, but not for other users unfortunately.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,257

    Re: Run-time Error on Method 'Open' of object '_Connection'

    Your code is late bound, so you don't need a reference. You do appear to have a typo in the extended properties - it should be:

    Please Login or Register  to view this content.
    not:

    Please Login or Register  to view this content.
    If that doesn't help, do you know what version of Office the problem machines have on them?
    Remember what the dormouse said
    Feed your head

  5. #5
    Forum Contributor
    Join Date
    09-19-2017
    Location
    London
    MS-Off Ver
    2015
    Posts
    169

    Re: Run-time Error on Method 'Open' of object '_Connection'

    Quote Originally Posted by rorya View Post
    Your code is late bound, so you don't need a reference
    Hi, Rorya

    May I know what late bound means?

    I have corrected the typo, still does not work on the other users. And our Office version is 2010, all of us.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,257

    Re: Run-time Error on Method 'Open' of object '_Connection'

    You declared your variables as Object - that's late binding.

    Are you all opening the same format workbooks? Your code is for xlsb files.

  7. #7
    Forum Contributor
    Join Date
    09-19-2017
    Location
    London
    MS-Off Ver
    2015
    Posts
    169

    Re: Run-time Error on Method 'Open' of object '_Connection'

    Quote Originally Posted by rorya View Post
    Are you all opening the same format workbooks? Your code is for xlsb files.
    Yes indeed, they should be using the same format workbooks.

  8. #8
    Forum Contributor
    Join Date
    09-19-2017
    Location
    London
    MS-Off Ver
    2015
    Posts
    169

    Re: Run-time Error on Method 'Open' of object '_Connection'

    Quote Originally Posted by rorya View Post

    If that doesn't help, do you know what version of Office the problem machines have on them?
    I just realized something, I found that my Office 2010 version is different:

    Attachment 703759

    Meanwhile other users' version is:

    Attachment 703760

    But in order for me to persuade my IT guy to somehow 'downgrade' other users' version to match with mine, I might need to pinpoint whether this is the actual cause. As what my IT dept mentioned, all versions under Microsoft 2010 have been standardized.

    I wonder if can this cause the issue I'm facing? From my understanding, other users' version is the latest one compared to mine.

    Any insight would be much appreciated. Thanks!

  9. #9
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,257

    Re: Run-time Error on Method 'Open' of object '_Connection'

    I can't see either of those attachments, I'm afraid. You need to use the Go Advanced button, then Manage attachments to properly attach images.

  10. #10
    Forum Contributor
    Join Date
    09-19-2017
    Location
    London
    MS-Off Ver
    2015
    Posts
    169

    Question Re: Run-time Error on Method 'Open' of object '_Connection'

    Oh, my bad. Didn't notice that.

    For my excel version, it's the image my_excel_sp1 (Version 14.0.06023.1000)

    Meanwhile, for the failed users', it's the image other_users_excel as attached (Version 14.0.07015.1000)
    Attached Images Attached Images

  11. #11
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,257

    Re: Run-time Error on Method 'Open' of object '_Connection'

    It seems odd to me that you'd have different versions in a corporate setting anyway!

    The error is usually down to a bad connection string (but you've corrected that) or missing OLEDB providers. You might ask IT or the users to check in the registry and make sure there is a HKEY_CLASSES_ROOT\Microsoft.ACE.OLEDB.12.0 key there.

  12. #12
    Forum Contributor
    Join Date
    09-19-2017
    Location
    London
    MS-Off Ver
    2015
    Posts
    169

    Re: Run-time Error on Method 'Open' of object '_Connection'

    Quote Originally Posted by rorya View Post
    The error is usually down to a bad connection string (but you've corrected that) or missing OLEDB providers. You might ask IT or the users to check in the registry and make sure there is a HKEY_CLASSES_ROOT\Microsoft.ACE.OLEDB.12.0 key there.
    I have checked their registry, and they do have the key mentioned I'm getting more confused now.

  13. #13
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,257

    Re: Run-time Error on Method 'Open' of object '_Connection'

    I suggest you try some simple code that opens a connection to one specific workbook using that provider, and see if it works. I'd also suggest using early binding in case you get a more descriptive error message.

+ 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. Run-time Error '1004' - Method 'Open' of object 'Workbooks' failed
    By caabdul in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-10-2019, 07:12 PM
  2. Run-time error 1004 - Method 'Open' of object "workbooks' failed
    By lmhc77 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-20-2018, 08:47 AM
  3. run time error 1004 method open of object workbooks failed
    By bennyamy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-24-2017, 05:09 PM
  4. Run-time error 1004 Method Open of object Workbooks Failed
    By Rikimaru82 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-29-2016, 04:32 AM
  5. [SOLVED] run-time error '1004' method 'open' of object 'workbooks' failed
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-03-2016, 06:24 PM
  6. vba method 'execute' of object '_Connection' failed
    By fmsd91 in forum Access Tables & Databases
    Replies: 3
    Last Post: 03-14-2016, 09:53 AM
  7. [SOLVED] Run-time error '1004': Method 'Open' of object 'Workbooks' failed
    By krish2503 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-14-2015, 06:11 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