Populating a column in Excel from MS Word

NMorales76

New Member
Joined
Nov 21, 2011
Messages
4
Hi, I am an intermediate MS Excel user and I have a question for those of you who are more savy. I am trying to figure out if it is possible to populate a field in Excel by reading the footer of a MS Word document. Has anyone had experience doing this sort of thing?

Thanks,
-Neil
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Hi Neil

The following code will get the footer's first word and place it in a cell...

Code:
Sub WordProbe()
Dim DocPath$, wApp As Word.Application

DocPath = ThisWorkbook.Path
Set wApp = CreateObject("Word.Application")
wApp.Visible = msoTrue
wApp.Documents.Open DocPath & "\Main2.docx"

With wApp
    .WordBasic.viewfooteronly
    .Selection.WholeStory
End With

Sheets("Sheet1").Range("e15").Value = wApp.Selection.Words(1)
Set wApp = Nothing

End Sub
 
Upvote 0
Hi Worf, thanks for the reply. However, there are more than one word that I need to get from the footer. Can I just change the value at the bottom of your code? Or is it more complex than that?
 
Upvote 0
Hi

This version will fetch all footer's text.

Code:
Sub WordProbe()
Dim DocPath$, wApp As Word.Application

DocPath = ThisWorkbook.Path
Set wApp = CreateObject("Word.Application")
wApp.Visible = msoTrue
wApp.Documents.Open DocPath & "\Main2.docx"

With wApp
    .WordBasic.ViewFooterOnly
    .Selection.WholeStory
End With

Sheets("Sheet1").Range("e15").Value = wApp.Selection.Text

Set wApp = Nothing

End Sub
 
Upvote 0
Hey I tried the code but it is giving me an error on the "wApp As word.Application" portion of it. It is saying that there is a "Compile Error - User-defined type not defined."
 
Upvote 0
Hi

In the VB window, go to Tools / References, and make sure the following is checked:

- Microsoft Office Object Library
- Microsoft Word Object Library

This should solve it...
 
Upvote 0

Forum statistics

Threads
1,216,076
Messages
6,128,669
Members
449,463
Latest member
Jojomen56

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top