How to Fix a Microsoft Project Excel Export Macro That Runs Only Once
Question details
A VBA macro designed to export Task Usage View data from Microsoft Project to Excel works successfully the first time but fails on subsequent executions.

- Product
- Microsoft Project / Microsoft Excel
- Device & OS
- not provided
- Scenario
- Exporting Task Usage View data from Microsoft Project to an Excel workbook using a VBA macro.
- Observed behavior
- The macro executes correctly on its first run but becomes unreliable and fails unpredictably during repeated executions, often due to direct copy-pasting from the Project view and residual data conflicts.
Ensure you have saved backups of both your Microsoft Project file and the target Excel workbook before modifying your VBA code.
Use the TimescaleData Method Instead of Copy-Paste
Replace direct copy-pasting from the Project view with the more reliable and efficient TimescaleData method in your macro.
Macros that perform large amounts of copying and pasting directly from the Project view are notoriously unreliable for repeated use. Transitioning your code to utilize the TimescaleData method ensures data is extracted programmatically, minimizing UI-based errors and clipboard conflicts.
In Microsoft Project, press ALT + F11 to open the Visual Basic for Applications (VBA) editor and locate your export macro module.
Locate the sections of your code that copy directly from the Task Usage View and remove the clipboard-dependent commands.
Implement the TimescaleData method to directly extract time-phased data from the project objects into variables, which can then be written directly to the target Excel cells.

Clear or Recreate the Target Excel Workbook
Ensure the destination Excel workbook is properly reset before each macro execution to prevent residual data conflicts.
Troubleshoot Extra Timescale Periods
Prevent the macro from breaking by properly handling periods where no Project data exists.
View and Analyze Exported Project Data with WPS Office
While Microsoft Project macros require specific MS Office integrations, you can seamlessly open, view, and analyze your exported Excel project data using WPS Office. It provides a lightweight, highly compatible alternative for all your spreadsheet needs without the heavy subscription fees.
- 1. Download WPS Office: Visit the official WPS website to download and install the free WPS Office suite on your computer.
- 2. Open WPS Spreadsheet: Launch the WPS Spreadsheet application to handle your newly exported Excel files.
- 3. Analyze Your Project Data: Open your exported .xlsx or .xlsm file to view, format, and analyze your time-phased project data without requiring Microsoft Excel.

Frequently Asked Questions
Why does my VBA macro fail on the second run?
Macros often fail on subsequent runs if object references to Excel are not properly released in the code, or if residual data from the first run disrupts the target pasting range.
What is the TimescaleData method in MS Project VBA?
The TimescaleData method is a programmatic way to extract time-phased information directly from tasks, resources, or assignments, avoiding the unreliability and slowness of UI copy-pasting.
How can I safely clear an Excel sheet using VBA?
You can use the Worksheet.Cells.Clear method targeting your specific worksheet inside the macro to erase all existing content and formatting before writing new data.
Can WPS Office open Excel files with macros?
Yes, WPS Office is highly compatible with Microsoft Excel formats and supports opening and viewing .xlsm files. Full VBA macro execution and editing support is available in professional versions of WPS Office.




