logo
search
VBA & Macro Problems

How to Resize, Center, and Recolor Word Charts with VBA

Bushra ParveenBushra Parveen Oct 15, 2026 869 views

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.

How to Resize, Center, and Recolor Word Charts with VBA
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 you start

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.

Solution 1Recommended

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.

1
Open the source file

Launch Excel and open the spreadsheet containing your original charts and text boxes.

2
Format and resize the chart

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.

3
Group objects

Hold the Shift key, select both the chart and the associated text boxes, right-click, and select 'Group' to bind them together.

4
Paste into Word

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.

Format and Adjust Charts in Excel Before Inserting into Word
Reliable Positioning: By completing layout adjustments in Excel, you bypass Word's complex anchoring rules, guaranteeing that your text boxes will not shift unexpectedly.
Advanced Document Formatting

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. 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. 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. 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.
High compatibility with Microsoft Word (.docx) and Excel (.xlsx) formatsStable object anchoring for charts and grouped text boxesBuilt-in Developer tab for testing and running VBA macros safelyLightweight, fast performance for handling large documents with multiple objects
microsoft office alternative - wps office

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.