How to Fix a Photo Macro Not Working in Excel
Question details
The user is trying to run a shared Excel workbook containing a specific macro to retrieve or insert photos. While other macros work fine and Trust Center settings are correct, the photo macro fails on the current computer despite working on another.
- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Executing a custom photo-retrieving VBA macro in a shared Excel worksheet on a different computer.
- Observed behavior
- The specific photo macro fails to execute or fetch the image on the current computer, whereas other macros in the same workbook function correctly.
Ensure that the exact folder structure for the photos exists on the new computer, as the macro may rely on specific hardcoded local paths or mapped network drives.
Verify File Paths in the VBA Code
Fix hardcoded file paths that point to locations or user profiles that only exist on the original computer.
Macros that retrieve external files often use absolute file paths (e.g., C:\Users\John\Pictures). When the workbook is moved to a new computer, these paths become invalid if the new PC has a different username or folder structure. Updating the VBA code to reflect the current PC's paths or using relative paths will resolve this.
Open your Excel workbook and press Alt + F11 to launch the Visual Basic for Applications (VBA) editor.
In the Project Explorer pane on the left, find the module containing your photo macro and double-click it to view the code.
Look through the code for any directory paths referencing the photos. Change these string values to match the exact folder location on your current computer, then save the workbook.
Check for Missing VBA References
Ensure that all required libraries and object dependencies used by the photo macro are active on the current computer.
Try WPS Office for Seamless Spreadsheet Management
If you are constantly dealing with compatibility issues, broken macros, or complex dependency setups in Microsoft Excel, consider trying WPS Office. It offers a lightweight, familiar interface and excellent format compatibility for your daily tasks.
- 1. Download and Install: Visit the official WPS website to download and install the free WPS Office suite on your computer.
- 2. Open Your Spreadsheet: Launch WPS Spreadsheet and open your existing Microsoft Excel workbook.
- 3. Edit and Save: Make your edits seamlessly and save the file in its original format without losing data compatibility.

Frequently Asked Questions
Why does an Excel macro work on one computer but not another?
This commonly happens due to differing environments. The new computer might have different hardcoded file paths (like a different Windows username), missing VBA library references, distinct macro security settings in the Trust Center, or missing external add-ins that the macro requires.
How do I fix a 'Compile error: Can't find project or library' in Excel VBA?
Open the VBA Editor (Alt + F11), navigate to Tools > References, and look for any checked library that says 'MISSING:'. Uncheck it and re-compile your code, or locate the required file on your new computer.
How can I share an Excel workbook with macros so the image paths don't break?
Store the images in the same folder as the Excel workbook and use relative paths in your VBA code (using ThisWorkbook.Path). Alternatively, embed the images directly into the worksheet or a UserForm so external files are no longer required.




