How to Write To A Word File Using Macros (VBA) in Excel Office 365?
Tags: towritetoawordfileus, vbamacros
Published: 2021-09-03 03:25:03

---
title: How to Write To A Word File Using Macros (VBA) in Excel Office 365?
published: true
date: 2021-09-03 01:37:27 UTC
tags: ToWriteToAWordFileUs,VBAMacros
canonical_url: https://geekexcel.com/how-to-write-to-a-word-file-using-macros-vba-in-excel-office-365/
---

In this article, you will learn the simple steps to **write to a Word File using Macros (VBA)**  **in Excel Office 365**. Let’s get them below!! Get an official version of MS Excel from the following link: **[https://www.microsoft.com/en-in/microsoft-365/excel](https://www.microsoft.com/en-in/microsoft-365/excel)**

## The Process Of Writing To A Word File Using Excel VBA

- Firstly, in the Excel Worksheet, you have to go to the **Developer Tab.**
- Then, you need to select the **Visual Basic** option under the **Code** section.

![](https://geekexcel.com/wp-content/uploads/2021/09/Select-Visual-Basic-1024x180.png)<figcaption>Select Visual Basic</figcaption>

- Now, you have to **copy and paste the code** given below.

```
 Sub WriteToWord()

   ''Using Early Binding

    'Dim wordApp As Word.Application

    'Dim mydoc As Word.Document

    'set wordApp=new word.Application 

    'Using late binding to create word application object

    'Declaring variables as objects

    Dim wordApp As Object

    Dim mydoc As Object

    'Initializing the object using CreateOBject Function

    Set wordApp = CreateObject("Word.Application")

    'Making word App Visible

    wordApp.Visible = True

    'Creating a new document

    Set mydoc = wordApp.Documents.Add()

    'Getting input from user

    myString = Application.InputBox("Write Your Text")

    'Writing to word

    wordApp.Selection.TypeText Text:=myString

    'inserting a new paragraph

    wordApp.Selection.TypeParagraph

End Sub 
```

- After that, you need to **save the code** by selecting it and then **close the window**.

![](https://geekexcel.com/wp-content/uploads/2021/09/Save-the-code.png)<figcaption>Save the Code</figcaption>

- Again, you have to go to the **Excel Spreadsheet** , and click on the **Developer Tab**.
- You need to choose the **Macros option** in the Code section.

![](https://geekexcel.com/wp-content/uploads/2021/09/Choose-Macro-option-1024x184.png)<figcaption>Choose Macro option</figcaption>

- Then, you have to make sure that your **macro name is selected** and click the **Run** button.

![](https://geekexcel.com/wp-content/uploads/2021/09/Click-on-Run.png)<figcaption>Click on the Run option</figcaption>

- Now, you will receive an **input** dialog box, and then you need to **type any text** in the text box.

![](https://geekexcel.com/wp-content/uploads/2021/09/Type-inuput-text.png)<figcaption>Type input text</figcaption>

- Finally, you will receive your **input text** in the **Word document**.

![](https://geekexcel.com/wp-content/uploads/2021/09/Input-text-in-word.png)<figcaption>Final Input text in Word</figcaption>

**Check this too:**

- [Shortcut to Open VBA Editor](https://geekexcel.com/shortcut-to-open-vba-editor-in-microsoft-excel-365/)
- [VBA InputBox Function](https://geekexcel.com/excel-vba-inputbox-function-office-365/)

## Verdict

In the above article, you can learn the simple steps to **write to a Word File using Macros (VBA)**  **in Excel Office 365**. Kindly, share your **feedback** in the below comment section. Thanks for visiting **[Geek Excel.](https://geekexcel.com/)** Keep Learning!

**Read Also:**

- **[How to Change Font Color in Microsoft Excel 2007?](https://geekexcel.com/how-to-change-font-color-in-microsoft-excel-2007/)**
- **[Excel Formulas to Count specific word in a range ~ Easy Tutorial!!](https://geekexcel.com/excel-formulas-to-count-specific-words-in-a-range/)**
- **[Excel Formulas to Get the Last Word of a Text String ~ Quick Method!!](https://geekexcel.com/excel-formulas-to-get-the-last-word-of-the-text-string/)**
- **[Count the Times a Word Appears in a Cell or a Range in Excel Office 365!!](https://geekexcel.com/count-the-times-a-word-appears-in-a-cell-or-a-range-in-excel-office-365/)**
- **[Excel Formulas to Remove the Last Word ~ Easy Tutorial!!](https://geekexcel.com/excel-formulas-to-remove-the-last-word-easy-tutorial/)**