Question about Word export to excel?

M

Mr BT

I cannot find a newsgroup for Word, it this might be applicable to what is
covered in this newsgroup so I'm going to ask this anyways...

Is there a way i can export the list of Bookmarks from a Word file ?

thx
Mr BT
 
C

Chip Pearson

In the VBA Editor, go to the Tools menu, choose References, and
select Microsoft Word. Then use code like the following:

Dim WordApp As Word.Application
Dim WordDoc As Word.Document
Dim Rng As Excel.Range
Dim BM As Word.Bookmark


Set Rng = Range("A1")
On Error Resume Next
Set WordApp = GetObject(, "Word.Application")
If WordApp Is Nothing Then
Set WordApp = CreateObject("Word.Application")
End If
If WordApp Is Nothing Then
MsgBox "Unable to access Word"
Exit Sub
End If

Set WordDoc = WordApp.Documents.Open(Filename:="H:\Test.doc")
'<<< CHANGE
For Each BM In WordDoc.Bookmarks
Rng.Value = BM.Name
Set Rng = Rng(2, 1)
Next BM



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Top