← Knowledge Base

QUAL2K and QUAL2Kw errors: Error 53, ThisWorkbook.Path, Simulation Aborted, Unexpected error

The QUAL2K error messages that come up most often in the qual2k-user group are four: "Run-time error 53", a ChDir (ThisWorkbook.Path) line highlighted in yellow, a run that ends with "... is aborted!" (often posted as "Simulation Aborted") and "Unexpected error". Several threads are still unanswered; one Error 53 thread, about QUAL2K 2.12b1, collects cases from 2019, 2021 and 2023 with no published fix. Most of them share one origin: the Excel workbook is not the model, but an interface that writes files to a folder, launches a Windows Fortran executable and reads what that executable leaves behind. When any link in that chain is not where the code expects it, an error appears. This guide explains the chain from the QUAL2Kw 5.1 VBA code and gives a concrete fix for each message.

Model the whole river in the prediction engine

Import your QUAL2Kw workbook or open the example project. Results reproduce 15 calibrated QUAL2Kw models within 5% or a small absolute band.

See the prediction engine

How QUAL2K runs under the hood

In QUAL2Kw 5.1, when you press the Fortran run button, the macros do this, in this order:

  1. Read the river name (B8), the file name (B9) and the save directory (B10) from the QUAL2K sheet. If B10 is empty, they use the folder of Workbooks(1). They check with Scripting.FileSystemObject that the folder exists; if not, they show "... is not a valid folder/path".
  2. Write the .q2k input file.
  3. Check numerical stability: if a reach may be unstable at the chosen time step, they stop with "The model may be unstable in reach ..." and recommend a shorter step.
  4. Write a message.dat file holding the paths of the .q2k and .out files, and delete the previous .out if there is one.
  5. Run ChDir (Workbooks(1).Path) and look for qual2kw5.exe in that folder; if it is not there, they show "Please copy qual2kw5.exe to ...".
  6. Launch the executable with Shell, wait for it to finish and read the .out. If that read fails, they show "... is aborted!".

Chapra's QUAL2K 2.12 is not identical: its manual also requires the workbook and the Fortran executable to sit in the same folder, but the code differs in detail (the ChDir (ThisWorkbook.Path) line users report does not appear in QUAL2Kw 5.1). We have not reviewed the QUAL2K 2.12 code; what follows is based on the QUAL2Kw VBA and on Microsoft's VBA documentation, and we mark where we infer.

Quick table

MessageMost likely causeFirst action
Run-time error 53A file the code looks for is not on the path (executable, .q2k, .out, message.dat)Press Debug and see which file the highlighted line uses
Stops at ChDir (ThisWorkbook.Path)The workbook's path is not a normal local folder (OneDrive, network, temporary attachment)Copy the folder to a short local path on C:
"... is aborted!" / Simulation AbortedThe executable failed during integration or left no readable .outRun with the VBA button to get its own stop message and a debugger line
"Cannot start ..."Windows could not launch the executableCheck that the .exe is not blocked or quarantined
"Unexpected error", Runtime error 11Wrong path, text in numeric cells, division by zeroCheck B10 and the input cells you changed
Buttons do nothing / security risk bannerOffice blocked the macros of a downloaded fileFile Properties, Unblock

1. Run-time error 53 (File not found)

According to Microsoft, Error 53 occurs when a statement such as Kill, Name or Open refers to a file that does not exist, or when the DLL named in a Declare statement cannot be found. In QUAL2K the candidates are the Fortran executable, the .q2k file, the .out file and message.dat. To find out which: in the error dialog press Debug and read the highlighted line and the path variables it uses (hover over them in the editor). The Error 53 reports in the user group come mostly from QUAL2K 2.12b1; in QUAL2Kw 5.1 a missing executable shows "Please copy qual2kw5.exe to ..." instead.

The causes we found reading the QUAL2Kw code:

  • The executable is not next to the workbook. QUAL2Kw looks for it in the workbook's folder, not in an install path. If you copied only the .xlsm, the .exe is missing.
  • The workbook folder is not the one you think. QUAL2Kw 5.1 uses Workbooks(1).Path, the first workbook open in that Excel session, and the HTS build uses ActiveWorkbook.Path. If another workbook was opened first, those paths point to its folder. A common case: if a hidden Personal Macro Workbook (PERSONAL.XLSB) loads when Excel starts, it is typically Workbooks(1), and the message then names your XLSTART folder. Check the VBA editor's Project Explorer for PERSONAL.XLSB and open QUAL2Kw as the first workbook in a fresh Excel session.
  • The file name in B9 or the path in B10 does not match what is on disk, for example after copying the project to another computer.

In one of the group threads, someone suggested checking the Courant number for an Error 53. Numerical stability matters, but it does not by itself produce a "file not found"; start with the paths.

2. Error at ChDir (ThisWorkbook.Path)

If the debugger highlights ChDir (ThisWorkbook.Path), the macro stopped while switching to the workbook's folder, before the model ran. That exact line is not in QUAL2Kw 5.1, which runs ChDir (Workbooks(1).Path); it comes from another QUAL2K build. Either way, the likely cause is a workbook path that is not a normal local folder:

  • OneDrive or SharePoint. When the workbook sits in a synced folder, ThisWorkbook.Path can return a web address (https://...) instead of a disk path, a behavior users report on Microsoft Q&A (a community report, not official documentation). ChDir cannot change to a URL.
  • File opened from an email or a .zip. Excel opens it from a temporary folder that holds neither the executable nor the .q2k files.
  • A network share. Users widely report that ChDir fails on network paths that start with \\server\...; Microsoft does not document this case, so treat it as a likely cause, not a certainty.

A quick test to rule out path problems: create C:\q2k\, copy the whole folder there (workbook, Fortran executable and .q2k files), unblock the workbook if Windows marked it as downloaded (see section 6), type C:\q2k in the save-directory cell, close Excel and open that workbook first. If it runs, the location was the problem; if it does not, keep going, because at least one user in the group reports that moving to C: alone did not help. Avoid spaces, accents and very long paths: QUAL2Kw stops if the full path of the .q2k file is longer than 260 characters.

3. "is aborted!" or "Model Execution Error - Simulation Aborted"

QUAL2Kw shows "... is aborted!" when the executable finished but its output could not be read. "Model Execution Error - Simulation Aborted" is how one user titled a thread about it, not the dialog text. The full QUAL2Kw message says the program "crashed during integration or there was a problem during output" and suggests checking for bad inputs, using a smaller time step, Runge-Kutta integration or adaptive time step integration. In most cases, then, it is a numerical or data problem, not a path problem. How to find it:

  • Run with the VBA button. It is slower, but it runs inside Excel, so instead of the executable's generic message you get the VBA's own stops (for example "SOD iterations exceeded") and a debugger line to inspect. Note that the VBA version does not accept time steps below a minimum and says so.
  • Read the pre-run checks. Before either run, QUAL2Kw stops if a reach may be unstable at the chosen time step and recommends a shorter one; the HTS build also checks for negative or zero flow in a reach and warns when a Courant number is above 1.
  • Reduce the time step and try another integration method, as the message itself suggests.
  • Check the flow balance: an abstraction larger than the available flow leaves a reach without water.
  • If you use sediment diagenesis option 1, the QUAL2Kw VBA stops the run with "SOD iterations exceeded" when the sediment oxygen demand iteration does not converge in 500 passes. Option 2 has no such cap in the VBA code, so a run that does not converge keeps iterating instead of stopping.

The message ends by asking you to send the .q2k file of the run to the model's author. Attach that file too when you post in the user group: without it, it is very hard for anyone to reproduce the problem.

4. "Cannot start ..." with Run Fortran

QUAL2Kw shows "Cannot start" followed by the executable's path when a runtime error occurs at the Shell call or right after it, once the code has confirmed the file exists. The most likely reading is that the .exe is there but Windows refused to start it. Check whether the antivirus quarantined or blocks it, and whether the folder allows running programs (some corporate policies forbid it in user or network folders). Those two causes are our inference, not something the message states. Meanwhile, the VBA button still works.

5. "Unexpected error" and Runtime error 11

In a thread on "Unexpected error" in QUAL2K 2.12, opened in 2017, later replies point to two causes: an incorrect save path and input cells holding words where a number is expected. Another user in the same thread reports runtime error 11 (division by zero). What to check:

  • That the directory cell (B10) holds a path that exists, with no quotes or trailing spaces.
  • That there is no text, no decimal commas pasted from another program and no formula errors in the input sheets.
  • That there are no zeros where the model divides: zero width or slope, a zero-length reach, zero headwater flow.
  • That the simulation month is a number from 1 to 12; QUAL2Kw validates it and shows its own message if not.

6. Macros do not run or the buttons do nothing

Since 2022, Office for Windows blocks macros by default in files downloaded from the internet or received by email, and shows a security risk banner without an "Enable content" button. A downloaded QUAL2K workbook falls exactly into that case. The fix Microsoft documents for a single file is to open its properties in Windows Explorer and tick Unblock on the General tab, or to save it in a trusted location. Do it only for files from a source you trust, such as the official model download.

If none of this works

Three ways out, from smallest to largest change:

  1. Try another Windows computer with the folder on C:. If it runs there, the problem is your environment (policies, antivirus, sync).
  2. Post in the qual2k-user group with the exact version, the full message, the line the debugger highlights and the .q2k file.
  3. Run the model without macros. Hydrolitica imports QUAL2Kw workbooks (.xls, .xlsx, .xlsm) and solves them with a Python port of the QUAL2Kw 5.1 solver from the browser, with no executable, no paths and no macros. It has limits worth knowing: it is validated against QUAL2Kw workbooks (5.1, HTS and xQUAL2Kw), not against Chapra's QUAL2K 2.12; it does not fix bad data, although its import report and warnings help find it; and it is not the original program. The Excel migration guide lists what the import carries over, and the validation methodology shows how the results were compared with the workbooks.

Related resources

Ready to model your own river?

Put what you just read into practice with the full QUAL2K prediction engine

Try the prediction engine for free