How to Resize, Center, and Recolor Word Charts with VBA
Question details
The user wants to run a VBA macro to bulk resize, center, and apply a color palette to charts in a Word document without moving or displacing the associated text boxes imported from Excel.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- Automating the formatting and positioning of multiple Excel-imported charts and their associated text boxes inside a Word document using VBA.
- Observed behavior
- When resizing or repositioning Word charts via VBA, the associated floating text boxes often move unexpectedly or become completely displaced from their intended positions relative to the charts.
Before running any new VBA scripts, verify the current text wrapping styles of your charts and text boxes, and ensure you test the macro on a duplicate copy of your document to prevent unintended layout changes.
Format and Adjust Charts in Excel Before Inserting into Word
The most reliable method to prevent text box displacement is to handle all resizing, centering, and coloring directly in Excel before pasting the charts into Word.
Word's chart anchoring and layout engine often conflicts with floating text boxes during VBA manipulation. Because Excel provides a much more stable canvas for chart objects and shapes, preparing them beforehand ensures they remain intact when transferred.
Launch Excel and open the spreadsheet containing your original charts and text boxes.
Use Excel's Chart Design tools or an Excel VBA macro to apply the desired color palette and adjust the width and height of the chart.
Hold the Shift key, select both the chart and the associated text boxes, right-click, and select 'Group' to bind them together.
Copy the grouped objects from Excel and paste them into your Word document. Use the 'Center' paragraph alignment in Word to correctly position the entire grouped object on the page.

Apply Fixed Wrapping and Anchors Using Word VBA
If you must process the charts inside Word, adjust your VBA code to lock anchors and use fixed text wrapping styles to keep text boxes intact.
Manage Charts and Macros Seamlessly with WPS Writer
WPS Office provides robust support for inserting charts, grouping text boxes, and executing advanced macros. You can easily manage object anchoring and text wrapping for complex document layouts without layout breaks.
- 1. Enable the Developer Tab: Open WPS Writer, go to the options menu to enable the Developer tab so you can access Macro and VBA tools.
- 2. Adjust Object Properties: Right-click any chart or text box, select 'Layout Options', and easily lock the anchor to prevent elements from shifting during formatting.
- 3. Run Formatting Macros: Click 'Macros' on the ribbon, paste your script for resizing and centering charts, and execute it across your document with precision.

Frequently Asked Questions
Why do my text boxes move when I resize a chart in Word?
Word relies on a system of object anchors to determine where floating elements belong. When you resize a chart, the layout of the document shifts, which can push the anchor paragraph to a new location. Consequently, any text box tied to that anchor will move as well.
Can I group the chart and text box in Word before running the macro?
Yes, grouping the chart and text boxes together can sometimes help preserve their relative positioning. However, both objects must have compatible text wrapping styles (like 'Square' or 'In Front of Text') before they can be grouped in Word.
How do I access the VBA editor to modify my macro settings?
You can access the VBA Editor by pressing Alt + F11 on your keyboard. Alternatively, you can enable the Developer tab in the ribbon and click the 'Visual Basic' or 'Macros' button to view and edit your scripts.
Is it better to use InlineShapes or Shapes for Word charts?
InlineShapes (objects that act like text characters) are generally more stable and less prone to unexpected shifting. If your charts do not require text to wrap around them closely, converting them to InlineShapes before running your macro can prevent text box displacement.




