VBA & Macro Problems

Fix Runtime Error 438: Paste Excel Range as Picture in Word VBA

WPS EditorWPS Editor Oct 9, 2026 873 views

Question details

The user needs to correctly paste an Excel range as a picture into a Word document using VBA and configure the Word document margins.

How to Fix Runtime Error 438 When Pasting an Excel Range as a Picture in Word via VBA
Product
Microsoft Excel / Word VBA
Device & OS
not provided
Scenario
Automating cross-application reporting by using a VBA macro to copy a specific range of cells in Excel and paste it as an image into a Word document.
Observed behavior
A Runtime error 438 occurs because the PasteSpecial method is being incorrectly called directly on a Word Document object instead of a Word Range object.
Before you start

Before running or modifying your macro, open the VBA Editor, go to Tools > References, and ensure the 'Microsoft Word Object Library' is checked to allow proper cross-application scripting.

Solution 1Recommended

Correct the PasteSpecial Target Object and Set Page Margins

Modify your VBA code to apply the PasteSpecial method to a Word Range object rather than the Document object, and configure your margins using the PageSetup property.

Runtime Error 438 ('Object doesn't support this property or method') triggers when you attempt to execute a command on an incompatible object. In Word VBA, the Document object does not support the PasteSpecial method directly; it must be applied to a specific Range or Selection within that document.

1
Target the Document Range

Locate the line in your macro attempting to paste the copied Excel data. Change the target from the document itself (e.g., MyDoc) to its range by adding '.Range'. Example: MyDoc.Range.PasteSpecial Placement:=wdInLine, DataType:=wdPasteEnhancedMetafile.

2
Configure Top, Bottom, and Right Margins

Access the PageSetup property of your Word Document object. Set the top, bottom, and right margins to zero using: MyDoc.PageSetup.TopMargin = 0, MyDoc.PageSetup.BottomMargin = 0, and MyDoc.PageSetup.RightMargin = 0.

3
Set a Custom Left Margin

Since margins often require specific units, use the InchesToPoints method for precise measurements. Apply it to the left margin like this: MyDoc.PageSetup.LeftMargin = Application.InchesToPoints(0.25).

4
Test the Macro

Save your VBA script and execute the macro from Excel. The selected range will now be pasted as a high-quality enhanced metafile image into Word without throwing Error 438.

Correct the PasteSpecial Target Object and Set Page Margins
Format Tip: Using the wdPasteEnhancedMetafile data type ensures your Excel range is pasted as a vector graphic. This keeps the text and gridlines crisp even if the picture is resized in Word.

Easily Paste Spreadsheet Ranges as Pictures in WPS Office

If you want to avoid dealing with complex VBA object models and runtime errors, WPS Office provides seamless, built-in tools to copy spreadsheet data and paste it directly as high-quality pictures into your text documents.

  1. 1. Copy the Range in Spreadsheet: Open your workbook in WPS Spreadsheet, highlight the specific cell range you want to export, and press Ctrl+C to copy it.
  2. 2. Switch to WPS Writer: Open your target document in WPS Writer (or switch to its tab if both are open in the same window) and click where you want the image to appear.
  3. 3. Paste as Picture: Go to the Home tab on the top ribbon, click the small dropdown arrow directly under the 'Paste' button, and choose 'Paste as Picture'.
  4. 4. Adjust Margins Using the Ruler: To adjust document margins, simply go to the Page Layout tab, click 'Margins', and set your custom top, bottom, left, and right measurements easily without code.
Built-in 'Paste as Picture' feature available directly from the user interface.Flawless cross-compatibility with Microsoft Excel (.xlsx) and Word (.docx) formats.Advanced Macro Editor available for pro users requiring robust VBA automation.Lightweight, fast-loading software with a convenient all-in-one tabbed workspace.
microsoft office alternative - wps office

Frequently Asked Questions

Why do I get Runtime Error 438 in my VBA macro?

Runtime Error 438 occurs when you call a method or property that the referenced object does not support. In this scenario, trying to use PasteSpecial directly on a Word 'Document' object triggers the error because it must be applied to a 'Range' or 'Selection' object instead.

What does wdPasteEnhancedMetafile mean in VBA?

wdPasteEnhancedMetafile is a built-in Word VBA constant that tells the PasteSpecial method to format the clipboard data as an Enhanced Metafile (.emf). This vector-based image format retains high quality and doesn't pixelate when you resize the pasted Excel table in your Word document.

How do I convert inches to points in an Office macro?

You can convert inches to points by using the built-in Application.InchesToPoints() function in your VBA code. For example, Application.InchesToPoints(0.25) converts a quarter of an inch into the exact point value required by the PageSetup property.