VBA & Macro Problems

Create a Formatted Word Document from Excel VBA Using a Template

Camila MilosovichCamila Milosovich Nov 20, 2026 869 views

Question details

Create a new Word document from Excel VBA with consistent font, spacing, and margin settings.

Create a Formatted Word Document from Excel VBA Using a Template
Product
Microsoft Excel and Microsoft Word
Device & OS
not provided
Scenario
An Excel macro needs to create a Word document with predefined formatting.
Observed behavior
Direct formatting through Excel VBA can produce object or method errors, and Word styles can override formatting.
Before you start

Make sure Microsoft Word is installed and that you can run macros in the Excel workbook. Choose a location for the Word template and note its full file path.

Solution 1Recommended

Create a Word template and use it from Excel VBA

Use a template to apply consistent formatting without setting each property through Excel VBA.

1
Set the default text formatting

In Word, create a blank document. On Home, right-click the Normal style and select Modify. Set the font to Courier New, size 9, then use Format > Paragraph to set single line spacing and 0 pt before and after paragraphs.

2
Set margins and save the template

In Word, open Layout > Margins and choose the required margins. Select File > Save As, choose Word Template (*.dotx), and save the file as MyTemplate.dotx.

3
Add the Excel macro

In Excel, open Developer > Visual Basic, select Insert > Module, and paste the following code. Replace the example path with the full path to your template: Sub CreateWordFromTemplate() Dim wrdApp As Object Dim wrdDoc As Object Set wrdApp = CreateObject("Word.Application") wrdApp.Visible = True Set wrdDoc = wrdApp.Documents.Add(Template:="C:\Templates\MyTemplate.dotx") End Sub

4
Run and save the document

In Excel, open Developer > Macros, select CreateWordFromTemplate, and click Run. In the new Word document, check the formatting and use File > Save As to save it as a document.

Create a Word template and use it from Excel VBA
Styles can affect the result: The Normal style applies where that style is used. If the document uses other styles, update those styles in the template as needed.
Free Microsoft Office alternative

Work with spreadsheets and documents in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with spreadsheets and documents. Its Microsoft Office format compatibility helps you move existing files into your workflow. The Excel-to-Word VBA automation described above requires Microsoft Office and is not a guaranteed WPS replacement.

Edit spreadsheet and document files in one office suiteOpen and work with Microsoft Excel XLSX and Word DOCX formatsUse a familiar interface that makes migration easierCreate and format documents with fonts, spacing, and margins
QA img-9

Frequently Asked Questions

Why use a Word template instead of formatting everything in VBA?

A template stores formatting such as styles and margins in Word. You can update those settings in the template instead of changing multiple VBA formatting commands.

What should I do if Excel cannot find the template?

Check the full path in the Documents.Add Template argument and confirm that the .dotx file exists at that location. Replace the example path with your actual template path.

Why does some text not use the Normal style formatting?

Text may use another Word style or direct formatting. Open the template in Word and check the relevant style under Home > Styles, then modify it if needed.

Can WPS Office run the same Excel-to-Word VBA macro?

The example uses Microsoft Word automation and is intended for Microsoft Excel and Word. WPS Office can work with XLSX and DOCX files, but the same VBA automation is not guaranteed to work in WPS.