VBA & Macro Problems

Remove an Embedded OLE Object That Freezes Excel with VBA

Adam DavisAdam Davis Nov 12, 2026 868 views

Question details

The user needs to remove an embedded email or OLE object that makes Excel stop responding or prevents the workbook from closing.

Product
Microsoft Excel
Device & OS
not provided
Scenario
An accidentally embedded object is freezing the active worksheet, and the user needs to delete it safely with VBA.
Observed behavior
Excel may stop responding or remain unable to close while the embedded OLE object is present.
Before you start

Save a backup copy of the workbook before editing it. Confirm which worksheet contains the embedded object and, if possible, note its position or order among the sheet's shapes.

Solution 1Recommended

Delete the embedded OLE object with an Excel VBA macro

Use this method when the embedded object prevents normal selection or deletion and you can open the Visual Basic Editor.

The macro targets the first shape on the active worksheet and deletes it only when it exposes an OLE format. If the embedded object has a different shape index, replace Shapes(1) with the correct index before running the code.

1
Open the Visual Basic Editor

Open the workbook in Excel, select the Developer tab, and click Visual Basic. If Developer is hidden, enable it through File > Options > Customize Ribbon.

2
Insert a standard module

In the Visual Basic Editor, choose Insert > Module to create a standard module, then paste this code: Sub RemoveEmbeddedObject() On Error Resume Next ActiveSheet.Shapes(1).OLEFormat.Delete End Sub

3
Run the removal macro

Click inside the RemoveEmbeddedObject procedure and choose Run > Run Sub/UserForm, or press F5. Make sure the worksheet containing the embedded object is active first.

4
Save and reopen the workbook

Return to Excel, save the workbook, close Excel completely, and reopen the file to confirm that it responds normally.

Check the shape index if needed: Shapes(1) assumes the embedded object is the first shape on the active sheet. If another shape comes first, change the index or inspect the worksheet's shapes to identify the correct object.
Free Microsoft Office alternative

Open and manage Excel workbooks with a lightweight WPS Office alternative

If the freeze is caused by Microsoft Excel's OLE or VBA handling, WPS Office provides a free, lightweight alternative for opening and editing compatible spreadsheets. Its familiar interface supports a smooth transition and helps preserve common Microsoft Office workbook formats during migration.

  1. 1. Install WPS Office: Download and install WPS Office, then launch WPS Spreadsheets from the main application screen.
  2. 2. Open the workbook: Choose Open from the home screen or select File > Open, then select the compatible Excel workbook.
  3. 3. Inspect the worksheet object: Select the affected worksheet and use the spreadsheet editing tools to locate, select, or remove the embedded object if it is supported in the imported file.
  4. 4. Save a compatible copy: Choose File > Save As and select an Excel-compatible .xlsx or .xls format when saving the edited workbook.
Open and edit common Excel workbooks with a familiar spreadsheet interface.Support for Microsoft Excel .xlsx and .xls formats for easier file exchange.Lightweight installation and free access for everyday spreadsheet work.Use familiar worksheet, object-selection, and file-management tools when moving away from Excel.
microsoft office alternative - wps office

Frequently Asked Questions

Why can an embedded email or OLE object make Excel freeze?

An OLE object can trigger an external application, damaged link, or unresponsive embedded-file handler. Excel may then stop responding or fail to close until the object is removed.

Does the VBA macro delete every object on the worksheet?

No. The macro targets only ActiveSheet.Shapes(1).OLEFormat. It assumes the first shape is the embedded OLE object and does not intentionally delete other shapes.

What should I do if Shapes(1) is not the frozen object?

Change the shape index in the macro, such as ActiveSheet.Shapes(2), after identifying the correct object. You can also use Home > Find & Select > Selection Pane when Excel remains responsive.

Can I run this macro if Excel will not open the workbook normally?

Try opening Excel in Safe Mode or opening the workbook without enabling content, then use the Visual Basic Editor if the file becomes accessible. If Excel remains completely unresponsive, work from a backup copy or use another compatible spreadsheet application to recover the workbook.