+ Reply to Thread
Results 1 to 6 of 6

Run-time error - file "cannot be accessed."

  1. #1
    Registered User
    Join Date
    02-18-2019
    Location
    Austin, TX
    MS-Off Ver
    Office 365
    Posts
    26

    Run-time error - file "cannot be accessed."

    I am using a VBA File Dialog to Save As my existing file to another name. That seems to work, but if I then go and manually use "Save" later, I get an error.
    Please Login or Register  to view this content.
    The debugger says that it is failing on this call:
    Please Login or Register  to view this content.
    The filename it's accessing cannot be read on screen, it runs off the edge of the dialog box. But I think it is an xml file within my main Excel file, with the same name.
    In other words, MyExcelFile \ MyExcelFile.xml.

    Any idea why that would be happening? It's true that file does not exist. But I don't get that error when saving the original file, and the file doesn't exist there either. In that case, the Export just fails. But if I save after I have used the 'Save As' dialog from VBA , I get the runtime error. I hope that explanation is clear.

    Thanks for any ideas about what could be causing this!

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    38,847

    Re: Run-time error - file "cannot be accessed."

    No idea what you're trying to do but I’d say you're a bracket short.

    So this
    Please Login or Register  to view this content.
    should probably be this
    Please Login or Register  to view this content.
    Last edited by TMS; 04-26-2019 at 03:11 AM.
    Trevor Shuttleworth - Excel Aid

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    02-18-2019
    Location
    Austin, TX
    MS-Off Ver
    Office 365
    Posts
    26

    Re: Run-time error - file "cannot be accessed."

    Thanks for the reply. Why do you say I would need the bracketed part? I did not write this code, so I don't know exactly either what the purpose is. But if I look at the XmlMaps.xml file within the Excel document's folder, there is this:
    Please Login or Register  to view this content.
    It looks to me like "strings_Map" is correct. And if I change the output filename to something that is not within the actual Excel file folder, then I get no error. It seems like some kind of permissions thing about writing into the Excel file's folder. And maybe that is not even what the original developer intended. It's just weird to me that it only generates a run-time error after I have used Save-As to change the name of the file.

    In any case, I am just going to ask if I can save it outside of the Excel file structure. Seems to me like that would have been the original intention...

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    38,847

    Re: Run-time error - file "cannot be accessed."

    It was meant to say
    Please Login or Register  to view this content.
    You don't have balanced brackets which is usually a prerequisite in most coding languages.

    That looks, to me, where the bracket should go ... but I could be wrong.

    If you didn't write the code, you should talk to the person who did.

  5. #5
    Registered User
    Join Date
    02-18-2019
    Location
    Austin, TX
    MS-Off Ver
    Office 365
    Posts
    26

    Re: Run-time error - file "cannot be accessed."

    Oh, I see. I'm sorry, that was a typo on my part. In the actual code, there is a right-parenthesis there like you have indicated.
    I think the error I'm getting has to do with trying to write inside the actual Excel file folder structure, and I got the OK to just export the XML file outside of there.
    Thanks for the replies.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    38,847

    Re: Run-time error - file "cannot be accessed."

    You're welcome.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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. [SOLVED] Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.
    By H.Gabor in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 07-26-2018, 06:36 AM
  2. Problem at saving sencond file in a loop "Run time error '9'"
    By tuxo99 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-19-2016, 05:40 AM
  3. Replies: 1
    Last Post: 10-24-2014, 12:32 AM
  4. Excel 2010 (Run-time error '13' type mismatch) "Debug" and "Continue" Grayed out.
    By Jeronimo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-18-2012, 06:42 PM
  5. "cannot be accessed" error message
    By Foz in forum Excel General
    Replies: 3
    Last Post: 07-14-2005, 08:05 PM
  6. [SOLVED] "file" cannot be accessed
    By FJB in forum Excel General
    Replies: 4
    Last Post: 05-18-2005, 12:06 AM
  7. Run-time Error "13" - File Type Mismatch
    By brentm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-10-2005, 02:06 PM

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