+ Reply to Thread
Results 1 to 4 of 4

adodb connection quirks

  1. #1
    Registered User
    Join Date
    04-25-2013
    Location
    toronto
    MS-Off Ver
    Excel 2003
    Posts
    58

    adodb connection quirks

    One part of my macro script will access another excel file on a shared server via ADODB jet engine. Everything seems to be working smoothly, except one small quirk. I can't seem to find any documentation of this so I am posting here to see if someone has come across this and found a solution.

    When the target file, the excel file on shared server, is not open for editing, my script will access it and transfer the necessary data over to my macro script. However, if it is ever opened by someone at the time of me opening an ADODB connection to it, my macro excel session will open the target file in as "readonly" file. In other words, my macro script will lose its focus and a new file is activated.

    This behaviour is largely unexpected and it causes my macro to fail.

    Please Login or Register  to view this content.
    Does someone know if there is any option or tricks that I can set in order that my macro script session will NEVER try to open the target file in its session if someone has that excel target file opened somewhere???

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: adodb connection quirks

    You can add some code to check to see if the workbook is open.

    Does this help

    http://stackoverflow.com/questions/9...open-using-vba

    ?
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Registered User
    Join Date
    04-25-2013
    Location
    toronto
    MS-Off Ver
    Excel 2003
    Posts
    58

    Re: adodb connection quirks

    Quote Originally Posted by nathansav View Post
    You can add some code to check to see if the workbook is open.

    Does this help

    http://stackoverflow.com/questions/9...open-using-vba

    ?



    Well, it helps in a way but it defeats the purpose of having the target file opened as READONLY file sharable by multiple access by my script. I would have set to mode to Exclusive access to achieve the same effect.

    My original design is to let various instances of the macro to access the target file simultaneously and draw its data across the network. If I set the file access mode to exclusive it is exactly same as checking if fileopen suggested by you.

    The reason is that as long as there is an ADO connection, the check will remain true so other instances cannot access the target file.

    Somehow the default behaviour of Excel is to open the workbook in a local session corresponding to the target file if it is opened by someone somewhere. I am asking for an ADOconnection which is supposed to be silent if the file remained closed.

    I suppose if the target file is something other than an Excel database then it will not do the same thing. If only I could find a way to change its default behaviour!

  4. #4
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: adodb connection quirks

    I did it the last time i did it, it was for a resource planner, mimicking MSP. What i did was to take a tmp copy of it, and do the SQL/ADO off the temp copy, then delete it, it all depends how "live" your data is???

+ 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. ADODB connection - start on 2nd row?
    By donyc in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-28-2011, 02:31 PM
  2. VBA and ADODB.Connection
    By AedanLee in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-29-2010, 06:37 AM
  3. ADODB Connection String
    By iancallaghan87 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-30-2008, 11:54 AM
  4. [SOLVED] ADODB Connection Problem
    By spardey in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-03-2005, 07:10 PM
  5. ADODB Connection String
    By Nigel C in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-20-2005, 03:05 AM

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