Excel VBA: Insert Multiple Pictures into Specific Cell Ranges in WPS Spreadsheets
Question details
The user needs a VBA macro that selects multiple image files and inserts them into separate fixed cell ranges, keeping each picture proportional, fitted to the range, and centered.

- Product
- WPS Spreadsheets
- Device & OS
- not provided
- Scenario
- Automating image placement in a worksheet so that selected pictures fill predefined ranges such as L82:P88, Q82:U88, and V82:Z88.
- Observed behavior
- The macro should open a multi-select file dialog, loop through each selected image, and place it in the next target range while preserving aspect ratio and centering it.
Keep the images in a known folder or in the same folder as the workbook if you plan to use ThisWorkbook.Path. In WPS Spreadsheets, save the workbook as a macro-enabled .xlsm file before adding VBA code.
Use a multi-select FileDialog macro to insert pictures into fixed ranges
Use this if you want to choose images manually and place them automatically into ranges like L82:P88, Q82:U88, and V82:Z88.
The macro uses Application.FileDialog with AllowMultiSelect = True, then calls an InsertPicture subroutine that preserves the original aspect ratio, scales the image to fit the target range, and centers it within the range.
This method matches the accepted Excel VBA approach and works in WPS Spreadsheets when macros are enabled.
In WPS Spreadsheets, press Alt+F11 to open the Microsoft Visual Basic for Applications editor.
In the VBA editor, click Insert > Module to create a new standard module for the picture insertion code.
Paste the VBA code that uses Application.FileDialog with AllowMultiSelect = True, defines ranges such as L82:P88, Q82:U88, and V82:Z88, and calls the InsertPicture subroutine for each selected file.
Press F5 or click Run > Run Sub/UserForm, select multiple images in the file dialog, and click Open.
Click Menu > Save As, set the file type to Excel Macro-Enabled Workbook (*.xlsm), and save the file in the workbook folder.
Automatically load images from the workbook folder with ThisWorkbook.Path
Use this if the images are stored in the same folder as the workbook and should load automatically when a button is clicked.
Insert multiple pictures into specific cell ranges with WPS Spreadsheets
Use the WPS Spreadsheets VBA editor to run a multi-select FileDialog macro that places each selected picture into a fixed range, preserves aspect ratio, and centers it. WPS Spreadsheets supports the Excel macro workflow and saves .xlsm workbooks, so you can automate image placement without changing your existing process.
- 1. Open a workbook in WPS Spreadsheets: Open WPS Office and create or open the workbook where you need to insert images.
- 2. Open the VBA editor: Press Alt+F11 to open the VBA editor and insert a new module from Insert > Module.
- 3. Paste and adapt the macro: Add the FileDialog macro code with the target ranges, then close the VBA editor.
- 4. Run the macro or assign it to a button: Run the macro from the VBA editor, or on the Developer tab click Insert > Button and assign the macro to a worksheet button.
- 5. Save as Excel Macro-Enabled Workbook: Click Menu > Save As and choose Excel Macro-Enabled Workbook (*.xlsm) so the macro remains available.

Frequently Asked Questions
Can this macro be used in WPS Spreadsheets exactly like in Excel?
Yes. WPS Spreadsheets supports VBA macros, including Application.FileDialog, and can save workbooks as Excel Macro-Enabled Workbook (.xlsm). Enable macros when opening or set macro security to trust the file.
How do I make the macro load images automatically from the workbook folder?
Use ThisWorkbook.Path to build image paths and loop through the expected file names. Store images in the same folder as the workbook and assign the macro to a button.
How do I stop pictures from being stretched?
Set LockAspectRatio to msoTrue before scaling, or calculate the scale by comparing target width and height, so each image fits the range without distortion.
Why does FileDialog only choose one image?
Set the FileDialog object's AllowMultiSelect property to True, otherwise the dialog returns only the last selected file.
How do I assign the macro to a button?
On the Developer tab, click Insert > Button, draw the button, and select the macro from the Assign Macro dialog.




