Results 1 to 4 of 4

Thread: Opening Excel....

  1. #1

    Thread Starter
    Addicted Member Guru's Avatar
    Join Date
    May 2000
    Location
    sulking in the cupboard under the stairs
    Posts
    237

    Question Opening Excel....

    I'm using:

    VB Code:
    1. Dim oConn As ADODB.Connection
    2.    Set oConn = New ADODB.Connection
    3. oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=filename.xls; Extended Properties=""Excel 8.0;HDR=NO;"""
    to access an Excel spreadsheet using ADO.

    But, if the spreadsheet is open it fails. What do I need to change to access a spreadsheet that it already open?

    Thanks
    Another light-hearted post from Guru

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Opening Excel....

    I suspect that you will need to specify the sharing mode in the connection string, otherwise it assumes that you want exclusive access to the file.. after a quick test I have found the following values:
    ;Mode=Read

    ;Mode=Share Deny None
    The first is most likely to solve it, but means that you will have read-only access. The second will attempt to allow you to write to it as well, but due to the nature of using files as databases I really would not trust it!

  3. #3

    Thread Starter
    Addicted Member Guru's Avatar
    Join Date
    May 2000
    Location
    sulking in the cupboard under the stairs
    Posts
    237

    Re: Opening Excel....

    Thanks for the suggestion.

    I only want to read the file and ";Mode=Read" didn't seem to make any difference
    Another light-hearted post from Guru

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Opening Excel....

    I've looked at the other properties that could be set, but none of them are relevant.. so I don't know what (if anything) can be done.

Posting Permissions

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



Click Here to Expand Forum to Full Width