How to Fix Excel VBA Error 4605 or 5097 on the Paste Line
Question details
The user needs to fix VBA runtime errors 4605 or 5097 that occur when a macro attempts to copy Excel cells and paste them into an Outlook email.

- Product
- Microsoft Excel / Outlook
- Device & OS
- not provided
- Scenario
- Running a VBA macro to copy spreadsheet data and paste it into a generated Outlook email message.
- Observed behavior
- The macro execution fails on the Paste command, throwing runtime error 4605 or 5097. In some cases, it also throws a compilation error stating 'Invalid use of property' on the subroutine declaration.
Ensure your macro security settings allow the execution of VBA code and verify that you have enabled the Microsoft Outlook Object Library reference in your VBA editor.
Explicitly Copy Ranges and Define Outlook Constants
Correct the VBA code by fully qualifying your Excel ranges, explicitly calling the copy method before pasting, and properly defining necessary Outlook constants.
Errors 4605 and 5097 often occur because the clipboard is empty by the time the paste command is executed, or because the Outlook object model is not properly instantiated. Fully qualifying your code prevents ambiguity between the Excel and Outlook applications.
Press ALT + F11 in Excel to open the Visual Basic for Applications (VBA) Editor.
Ensure your code is placed inside a standard module (Insert > Module) rather than a Worksheet or ThisWorkbook module.
Declare the required Outlook constants explicitly at the beginning of your script. For example, add the line: Const olMailItem = 0.
Qualify the range completely before copying. Use code like ThisWorkbook.Sheets("Sheet1").Range("A1:Z60").Copy to ensure the correct data is placed in the clipboard immediately before the Outlook paste operation.
Run the macro again to test if the paste operation into the Outlook email completes successfully without triggering the 4605 or 5097 runtime error.

Test the Macro in a Clean Workbook
Isolate the issue by testing the core VBA logic in a brand-new Excel file to rule out workbook corruption or conflicting background macros.
Try WPS Office for Seamless Spreadsheet and Macro Compatibility
If you frequently encounter VBA runtime errors, object library conflicts, or overall compatibility issues in Microsoft Office, consider trying WPS Office. It offers robust support for macros and provides a lightweight, highly compatible alternative for your complex spreadsheet workflows.

Frequently Asked Questions
What does Excel VBA runtime error 4605 mean?
Error 4605 typically occurs when a requested method or property is not available at the current time. In the context of pasting into Outlook, it usually means the clipboard is empty, the target document area is locked, or the WordEditor object within the email hasn't fully initialized before the paste command executes.
Why am I getting a 'Compilation error: Invalid use of property' on my Sub line?
This compilation error happens when you name a macro using a reserved word or an existing property name. For example, if you name a module or a variable the same as your Sub name, VBA gets confused. Renaming your subroutine to a unique identifier will resolve this.
How do I add the Outlook Object Library reference in Excel VBA?
In the VBA Editor, click on 'Tools' in the top menu bar, then select 'References'. Scroll down the alphabetical list until you find 'Microsoft Outlook XX.X Object Library' (where XX.X is your version number), check the box next to it, and click 'OK'.




