logo
search
VBA & Macro Problems

How to Set a PowerPoint Background from an Embedded Excel Picture Using VBA

Phi Hung VoPhi Hung Vo Oct 9, 2026 869 views

Question details

The user wants to use VBA to set PowerPoint slide backgrounds using pictures that are embedded directly within an Excel workbook, without keeping permanent image files saved on the disk.

How to Set a PowerPoint Background from an Embedded Excel Picture Using VBA
Product
Microsoft Excel / PowerPoint (VBA)
Device & OS
not provided
Scenario
Automating presentation creation by transferring images from Excel to PowerPoint backgrounds via VBA scripts.
Observed behavior
A method is needed to extract embedded Excel images, apply them as slide backgrounds in PowerPoint, and ensure no permanent files are left behind on the local drive.
Before you start

Ensure you have enabled the Developer tab in Excel and have set the necessary reference to the Microsoft PowerPoint Object Library in your VBA editor.

Solution 1Recommended

Use VBA to Export to a Temporary File and Set as Slide Background

This approach extracts the image to a temporary file, sets it as the slide background, and then immediately deletes the file to keep your system clean.

Because the PowerPoint object model requires a physical file path to assign a user picture to a slide background, you cannot directly pass an image from system memory or the clipboard. Creating a temporary file is the most efficient workaround.

1
Open the VBA Editor

Press Alt + F11 in Excel to open the VBA Editor, then click Insert > Module to create a new script area.

2
Add PowerPoint Reference

Go to Tools > References in the top menu, scroll down, and check the box next to 'Microsoft PowerPoint Object Library'.

3
Extract Image via Chart Object

Write VBA code to copy the target Shape in Excel, paste it into an empty temporary Chart object, and use the Chart.Export method to save it as a temporary JPG in your local AppData or Temp folder.

4
Apply Background in PowerPoint

Use PowerPoint VBA objects to set the background. For example, use Slide.Background.Fill.UserPicture("C:\Temp\temp.jpg") to point the slide background to your newly created temporary file.

5
Delete the Temporary File

Once the background is applied, use the VBA Kill statement (e.g., Kill "C:\Temp\temp.jpg") to permanently remove the temporary image file from your hard drive.

Use VBA to Export to a Temporary File and Set as Slide Background
Chart Export Trick: Since VBA cannot easily save an Excel Shape directly as an image file, placing the shape inside a temporary Chart object and exporting that chart is the standard and most reliable VBA workaround.

Automate Spreadsheets and Presentations with WPS Office Macros

WPS Office features a robust built-in Macro Editor that supports VBA, allowing you to seamlessly automate workflows like transferring images between WPS Spreadsheets and WPS Presentation.

  1. 1. Open WPS Spreadsheets: Launch WPS Office and open your workbook containing the embedded images you wish to export.
  2. 2. Access the Macro Editor: Navigate to the Tools tab on the top ribbon and click on 'Macro Editor' to launch the VBA-compatible scripting environment.
  3. 3. Run the Cross-App Macro: Paste and execute your VBA script to extract the embedded image, launch WPS Presentation, and set it as the slide background.
  4. 4. Save as Macro-Enabled Format: Go to Menu > Save As and select the highly compatible .xlsm format to retain your automated scripts for future use.
Built-in VBA-compatible Macro Editor for complex automationSeamlessly extract data and images between Spreadsheets and PresentationsFull compatibility with Microsoft Office macro formats (.xlsm, .pptm, .docm)Lightweight installation with a familiar user interface
microsoft office alternative - wps office

Frequently Asked Questions

Why can't I assign an Excel shape to a PowerPoint background directly from the clipboard?

The PowerPoint VBA API for setting user pictures (UserPicture) strictly requires a physical file path. It does not accept a clipboard object or an image directly from system memory, making the temporary file creation step mandatory.

How do I ensure the temporary file gets deleted even if the code crashes?

You should implement error handling in your VBA script using 'On Error GoTo' statements. In your error-handling block at the end of the script, include the 'Kill' command to safely delete the temporary file before the script entirely exits.

Is there a specific image format I should use for the temporary file?

JPG or PNG formats are highly recommended for the Chart.Export method. PNG is preferable if your embedded Excel images have transparency, ensuring the final PowerPoint slide background maintains high visual quality.