GetObject opening a file as Read-Only!!-VBForums
Results 1 to 7 of 7

Thread: GetObject opening a file as Read-Only!!

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2015
    Posts
    5

    GetObject opening a file as Read-Only!!

    Hi All

    I would really appreciate some help on this one. I am really confused!

    For years I have successfully used a program that I wrote in Word 2010. Now all of a sudden I gave it to a friend to use and it no longer works.

    The program is run from within Microsoft Word and it uses GetObject to open up an excel document as follows:

    Set wbT = GetObject(Location2, "Excel.Sheet")

    (I have defined

    Const Location2 As String = "\MVAA\Test2.xlsx")

    When my friend runs this code in Word 2013 it opens up the excel file as Read-only and then later crashes when the code tries to save the excel document. I cant figure out why it is opening as Read only. The excel file itself is definitely not Read-only and only the code causes this to happen.

    My friend is running Win 7 and using Office 2013. Is this a bug in Office 2013?

    Any suggestions would be greatly appreciated!

    Thanks a lot

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    22,963

    Re: GetObject opening a file as Read-Only!!

    possibly folder permissions or virtualization issue

    for test purposes try a workbook in documents or some other user location
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2015
    Posts
    5

    Re: GetObject opening a file as Read-Only!!

    Thanks. What exactly is a virtualization issue and how can I avoid it?

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2015
    Posts
    5

    Re: GetObject opening a file as Read-Only!!

    By the way I tested it on 3 independent computers all running Office 2013 and all 3 had the same issue. However it works on multiple PC's running 2010.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jun 2015
    Posts
    5

    Re: GetObject opening a file as Read-Only!!

    Good news - I managed to figure out the problem (although I don't understand it)!

    Instead of having GetObject(Location2, "Excel.Sheet") i just have GetObject(Location2). It now works in Office 2013 as well!!

    I would be interested to hear any explanations for this.

    Thanks

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    22,963

    Re: GetObject opening a file as Read-Only!!

    i can not help with that as i have never used with the excel.sheet parameter anyway

    they have redefined many of the objects within excel for 2013, maybe some minor difference, maybe i will do some testing later
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7

    Thread Starter
    New Member
    Join Date
    Jun 2015
    Posts
    5

    Re: GetObject opening a file as Read-Only!!

    Ok thanks a lot.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.