How To Control Excel from Word using VBA in Microsoft Excel 2010?
Tags: tocontrolexcelfromwo, vbamacros
Published: 2021-10-08 09:17:29

---
title: How To Control Excel from Word using VBA in Microsoft Excel 2010?
published: true
date: 2021-10-07 11:49:35 UTC
tags: ToControlExcelFromWo,VBAMacros
canonical_url: https://geekexcel.com/how-to-control-excel-from-word-using-vba-in-microsoft-excel-2010/
---

In this tutorial, you will learn how to  **control Excel**  **from Word**  **using VBA ** in Microsoft Excel 2010. Let’s see them below!! Get the 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)

## Example

- 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.

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

- Now, you have to click on the  **Insert ** and select  **Module**.

![Insert a module](https://geekexcel.com/wp-content/uploads/2021/09/Insert-a-module.png)<figcaption>Insert a module</figcaption>

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

```
Option Explicit
Sub OpenAndReadWordDoc()
Dim tString As String
Dim p As Long, r As Long
Dim wrdApp As Object, wrdDoc As Object
Dim wb As Workbook
Dim trange As Variant
Set wb = Workbooks.Add
With wb.Worksheets(1).Range(“A1”)
.Value = “Word Document Contents:”
.Font.Bold = True
.Font.Size = 14
.Offset(1,0).Select
End With
r = 3
Set wrdApp = CreateObject(“Word.Application”)
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Open(“B:\Test\MyNewWordDoc.docx”)
With wrdDoc
For p = 1 to .Paragraphs.Count
Set trange = .Range(Start:=.Paragraphs(p).Range.Start, _
End:=.Paragraphs(p).Range.End)
tString = trange.Text
tString = Left(tString, Len(tString)-1)
If Instr(1, tString,”1”) > 0 Then
wb.Worksheets(1).Range(“A” & r).Value = tString
r=r+1
End If
Next p
.Close
End With
wrdApp.Quit
Set wrdDoc = Nothing
Set wrdApp = Nothing
wb.Saved = True
End Sub

```

- You need to  **save the code**  by selecting it and then  **close the window**.

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

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

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

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

![](https://geekexcel.com/wp-content/uploads/2021/10/Run-the-Code-20.png)<figcaption>Run the Code</figcaption>

- Finally, you will get the  **output ** as given below in  **Microsoft Excel**.

![](https://geekexcel.com/wp-content/uploads/2021/10/Output-16.png)<figcaption>Output</figcaption>

## Sum-Up

In the above short tutorial, we have illustrated ** ** how to  **control Excel from Word using VBA ** in Microsoft Excel 2010. Hope you like this article. Please feel free to state your  **query**  or  **feedback**  for the above article. Thank you so much for Reading!! To learn more, check out **[Geek Excel](https://geekexcel.com/)!! **And [**Excel Formulas**](https://geekexcel.com/excel-formula/) **!!**

**Related Articles:**

- **[How To Control Word from Excel using VBA in Microsoft Excel 2010?](https://geekexcel.com/how-to-control-word-from-excel-using-vba-in-microsoft-excel-2010/)**
- **[Easy Shortcut to Move to the Previous Control in Excel 365!!](https://geekexcel.com/easy-shortcut-to-move-to-the-previous-control-in-excel-365/)**
- **[Simple Shortcut to Move to the Next Control in MS Excel 365!!](https://geekexcel.com/simple-shortcut-to-move-to-the-next-control-in-ms-excel-365/)**
- **[Shortcuts for Dialog Box Options in MS Excel 365!!](https://geekexcel.com/shortcuts-for-dialog-box-options-in-ms-excel-365/)**
- **[Excel Formulas to Count specific word in a range ~ Easy Tutorial!!](https://geekexcel.com/excel-formulas-to-count-specific-words-in-a-range/)**