Create a Formatted Word Document from Excel VBA Using a Template
Question details
Create a new Word document from Excel VBA with consistent font, spacing, and margin settings.

- 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.
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.
Create a Word template and use it from Excel VBA
Use a template to apply consistent formatting without setting each property through Excel VBA.
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.
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.
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
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.

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.

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.




