Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Import Excel Error r(603)

    Hi,

    I am trying to import Excel files into Stata. The Excel files contain multiple worksheets and are password-protected. I get an error message r(603) that the Excel file cannot be loaded for about 35% of the files. I've opened these Excel files and re-saved them, but I still get the same error. I'm not sure what is happening, especially since this only happens for a subset of files.

    Code:
    global raw "\data"
    global batch "1st batch"
    global files: dir "${raw}Suntec\\${batch}" files "*.xlsx", respectcase
    foreach file of global files {
         global openfile "${raw}Ardem/${batch}/`file'"
         import excel using "${openfile}", sheet("General Info") allstring clear
    ...
    }
    Thanks,
    Simone

  • #2
    Make sure no other program has that file opened.
    This includes Excel itself and any other program that has produced the file or is watching the file. Including other users on the net-shared folders/drives.

    Comment


    • #3
      Ok, I've checked that, and it looks like another program had it open. Thanks for your assistance.

      Comment


      • #4
        I had a similar problem when importing and exporting excel file. A few things that you can try or pay attention to:

        First I find the xlsx file more stable than the xls files and therefore tends to prefer xlsx.

        Second, you may want to uninstall any add-in on excel: these slow down the opening process.

        Third, if your files are saved on a cloud server (db, box...), I noticed that it may create issues. Try the same loop on your local computer and see if it helps

        forth, I would use the command "sleep" to slow down the opening/saving process for a few millisecond. For instance do sleep 2000 between each loop will help considerably.

        I do not understand the reason for this issue though. Be nice if stata will look into it.

        Any idea we are having these issues ?

        Comment

        Working...
        X