How do I export a list of bookmarks from a document?

S

Shawn

I am working with an existing word doc that is linked via bookmarks to an
excel doc and I am trying to figure out which bookmarks in the word doc go to
which cells in the excel doc. My first step is to get a list of bookmarks in
the word doc. Is there a way to extract a list of those?
 
G

Greg Maxey

This will give you a simple list in a new document.

Sub ScatchMacro()
Dim oDoc1 As Document
Dim oDoc2 As Document
Dim oBM As Bookmark
Set oDoc1 = ThisDocument
Set oDoc2 = Documents.Add
For Each oBM In oDoc1.Bookmarks
oDoc2.Range.InsertAfter oBM.Name & vbCr
Next oBM
End Sub
 
S

Shawn

Thanks

Greg Maxey said:
This will give you a simple list in a new document.

Sub ScatchMacro()
Dim oDoc1 As Document
Dim oDoc2 As Document
Dim oBM As Bookmark
Set oDoc1 = ThisDocument
Set oDoc2 = Documents.Add
For Each oBM In oDoc1.Bookmarks
oDoc2.Range.InsertAfter oBM.Name & vbCr
Next oBM
End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
 
G

Graham

Hi, I hope you don't mind me hi-jacking this thread? I'm trying to do the
same thing, and the macro is running but I'm getting a blank result in a new
document.
I've changed the oDoc1 to the name of the source document (the one with the
bookmarks) and the oDoc2 to a blank Word doc, in Line 2,3,4,5,6 & 7
respectively.
I've had to omit the file tag e.g. .doc as the prog didn't like them ?
Where am I going wrong ?
Regards
Graham
 
G

Graham

Sorry, should have included the code as it now stands, where
CopyofCarl1192.doc is the source document & Document4.doc is a new blank
document:

Sub Extractingbookmark()
Dim CopyofCARL1192 As Document
Dim Document4 As Document
Dim oBM As Bookmark
Set Document4 = ThisDocument
Set CopyofCARL1192 = Documents.Add
For Each oBM In CopyofCARL1192.Bookmarks
Document4.Range.InsertAfter oBM.Name & vbCr
Next oBM
End Sub
 
G

Greg Maxey

The code was written to be ran from the document containing the bookmarks.
Open that document, open the VB Editor, insert the code and run it as is.


Hi, I hope you don't mind me hi-jacking this thread? I'm trying to do
the same thing, and the macro is running but I'm getting a blank
result in a new document.
I've changed the oDoc1 to the name of the source document (the one
with the bookmarks) and the oDoc2 to a blank Word doc, in Line
2,3,4,5,6 & 7 respectively.
I've had to omit the file tag e.g. .doc as the prog didn't like them ?
Where am I going wrong ?
Regards
Graham

--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org


McCain/Palin '08 !!!
 
G

Greg Maxey

Graham,

In that case you need to "open" CopyofCarl1192.

Sub Extractingbookmark()
Dim CopyofCARL1192 As Document
Dim Document4 As Document
Dim oBM As Bookmark
Set Document4 = ThisDocument
Set CopyofCARL1192 = Documents.Open("C:\COPYOFCARL1192.doc") 'Change the
path and file name as required.
For Each oBM In CopyofCARL1192.Bookmarks
Document4.Range.InsertAfter oBM.Name & vbCr
Next oBM
CopyofCARL1192.close wdDoNotSaveChanges
End Sub



Sorry, should have included the code as it now stands, where
CopyofCarl1192.doc is the source document & Document4.doc is a new
blank document:

Sub Extractingbookmark()
Dim CopyofCARL1192 As Document
Dim Document4 As Document
Dim oBM As Bookmark
Set Document4 = ThisDocument
Set CopyofCARL1192 = Documents.Add
For Each oBM In CopyofCARL1192.Bookmarks
Document4.Range.InsertAfter oBM.Name & vbCr
Next oBM
End Sub

--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org


McCain/Palin '08 !!!
 
G

Graham

Many Thanks, Obvious when you know how!!
I'll try again, but probably not til tomorrow.
Regards
Graham
 
G

Graham

Many Thanks Greg, worked fine this time. Not as useful as I had hoped however
as I now have a list of 147 sequential bookmarks "Insert103". I was hoping it
would tell me what they actually were e.g "Insert103-FirstName" I may well
start a new thread for resources on 'Bookmark Basics', I don't seem to be
able to find much basic information on How they work, How to use them etc.
 
G

Greg Maxey

Graham,

Are you trying to list the both the bookmark name and what is being
bookmarked (i'ts text)?
Sub ScatchMacro()
Dim oDoc1 As Document
Dim oDoc2 As Document
Dim oBM As Bookmark
Set oDoc1 = ThisDocument
Set oDoc2 = Documents.Add
For Each oBM In oDoc1.Bookmarks
oDoc2.Range.InsertAfter oBM.Name & " - " & oBM.Range.Text & vbCr
Next oBM
End Sub

Many Thanks Greg, worked fine this time. Not as useful as I had hoped
however as I now have a list of 147 sequential bookmarks "Insert103".
I was hoping it would tell me what they actually were e.g
"Insert103-FirstName" I may well start a new thread for resources on
'Bookmark Basics', I don't seem to be able to find much basic
information on How they work, How to use them etc.

--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org


McCain/Palin '08 !!!
 
G

Graham

HI Greg, Thanks again for helping on this, the code worked fine, but what I
was really after was the title of the source, rather than the actual text e.g.
Bookmark 'insert32' = "Surname Field" etc. etc. I collected all this by
working manually through the form, bit tedious, but got there!
I'm still not 100% sure that I know the proper application of bookmarks,
hence now after more resources.
 
P

Philip Suding

Hello- This is great. After much searching, this looks exactly like what I'm looking for too. I'd like the name of the bookmark. I hope someone can work this out. -Thanks



Graha wrote:

HI Greg, Thanks again for helping on this, the code worked fine, but what I
17-Oct-08

HI Greg, Thanks again for helping on this, the code worked fine, but what
was really after was the title of the source, rather than the actual text e.g
Bookmark 'insert32' = "Surname Field" etc. et

Previous Posts In This Thread:

How do I export a list of bookmarks from a document?
I am working with an existing word doc that is linked via bookmarks to a
excel doc and I am trying to figure out which bookmarks in the word doc go t
which cells in the excel doc. My first step is

This will give you a simple list in a new document.
This will give you a simple list in a new document


-
Greg Maxey/Word MV
See
http://gregmaxey.mvps.org/word_tips.ht
For some helpful tips using Word

Shawn wrote:

This will give you a simple list in a new document.
This will give you a simple list in a new document

Sub ScatchMacro(
Dim oDoc1 As Documen
Dim oDoc2 As Documen
Dim oBM As Bookmar
Set oDoc1 = ThisDocumen
Set oDoc2 = Documents.Ad
For Each oBM I

Re: How do I export a list of bookmarks from a document?
Thank

:

Hi, I hope you don't mind me hi-jacking this thread?
Hi, I hope you do not mind me hi-jacking this thread? I am trying to do th
same thing, and the macro is running but I am getting a blank result in a ne
document
I have changed the oDoc1 to the name

Sorry, should have included the code as it now stands, where CopyofCarl1192.
Sorry, should have included the code as it now stands, wher
CopyofCarl1192.doc is the source document & Document4.doc is a new blan
document

Sub Extractingbookmark(
Dim CopyofCARL1192 As Document

The code was written to be ran from the document containing the bookmarks.
The code was written to be ran from the document containing the bookmarks
Open that document, open the VB Editor, insert the code and run it as is


Graham wrote

-
Greg Maxey - Word MV

My web

Graham,In that case you need to "open" CopyofCarl1192.
Graham

In that case you need to "open" CopyofCarl1192

Sub Extractingbookmark(
Dim CopyofCARL1192 As Documen
Dim Document4 As Documen
Dim oBM As Bookmar
Set Document4 = ThisDocumen
Set CopyofC

Many Thanks, Obvious when you know how!!
Many Thanks, Obvious when you know how!
I will try again, but probably not til tomorrow
Regard
Graha

:

Many Thanks Greg, worked fine this time.
Many Thanks Greg, worked fine this time. Not as useful as I had hoped howeve
as I now have a list of 147 sequential bookmarks "Insert103". I was hoping i
would tell me what they actually were e.g "I

Graham,Are you trying to list the both the bookmark name and what is being
Graham

Are you trying to list the both the bookmark name and what is bein
bookmarked (i'ts text)
Sub ScatchMacro(
Dim oDoc1 As Documen
Dim oDoc2 As Documen
Dim oBM As Bookmar
Set oDoc1 = ThisD

HI Greg, Thanks again for helping on this, the code worked fine, but what I
HI Greg, Thanks again for helping on this, the code worked fine, but what
was really after was the title of the source, rather than the actual text e.g
Bookmark 'insert32' = "Surname Field" etc. et

EggHeadCafe - Software Developer Portal of Choice
Visual Basic.NET and the .NET Platform [aPress]
http://www.eggheadcafe.com/tutorial...912-35144a12f26e/visual-basicnet-and-the.aspx
 
D

Doug Robbins - Word MVP

The name of which bookmark?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
Hello- This is great. After much searching, this looks exactly like what
I'm looking for too. I'd like the name of the bookmark. I hope someone can
work this out. -Thanks



Graha wrote:

HI Greg, Thanks again for helping on this, the code worked fine, but what
I
17-Oct-08

HI Greg, Thanks again for helping on this, the code worked fine, but what
I
was really after was the title of the source, rather than the actual text
e.g.
Bookmark 'insert32' = "Surname Field" etc. et

Previous Posts In This Thread:

How do I export a list of bookmarks from a document?
I am working with an existing word doc that is linked via bookmarks to an
excel doc and I am trying to figure out which bookmarks in the word doc go
to
which cells in the excel doc. My first step is

This will give you a simple list in a new document.
This will give you a simple list in a new document.



--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Shawn wrote:

This will give you a simple list in a new document.
This will give you a simple list in a new document.

Sub ScatchMacro()
Dim oDoc1 As Document
Dim oDoc2 As Document
Dim oBM As Bookmark
Set oDoc1 = ThisDocument
Set oDoc2 = Documents.Add
For Each oBM I

Re: How do I export a list of bookmarks from a document?
Thanks

:

Hi, I hope you don't mind me hi-jacking this thread?
Hi, I hope you do not mind me hi-jacking this thread? I am trying to do
the
same thing, and the macro is running but I am getting a blank result in a
new
document.
I have changed the oDoc1 to the name

Sorry, should have included the code as it now stands, where
CopyofCarl1192.
Sorry, should have included the code as it now stands, where
CopyofCarl1192.doc is the source document & Document4.doc is a new blank
document:

Sub Extractingbookmark()
Dim CopyofCARL1192 As Document

The code was written to be ran from the document containing the bookmarks.
The code was written to be ran from the document containing the bookmarks.
Open that document, open the VB Editor, insert the code and run it as is.



Graham wrote:

--
Greg Maxey - Word MVP

My web

Graham,In that case you need to "open" CopyofCarl1192.
Graham,

In that case you need to "open" CopyofCarl1192.

Sub Extractingbookmark()
Dim CopyofCARL1192 As Document
Dim Document4 As Document
Dim oBM As Bookmark
Set Document4 = ThisDocument
Set CopyofC

Many Thanks, Obvious when you know how!!
Many Thanks, Obvious when you know how!!
I will try again, but probably not til tomorrow.
Regards
Graham

:

Many Thanks Greg, worked fine this time.
Many Thanks Greg, worked fine this time. Not as useful as I had hoped
however
as I now have a list of 147 sequential bookmarks "Insert103". I was hoping
it
would tell me what they actually were e.g "I

Graham,Are you trying to list the both the bookmark name and what is being
Graham,

Are you trying to list the both the bookmark name and what is being
bookmarked (i'ts text)?
Sub ScatchMacro()
Dim oDoc1 As Document
Dim oDoc2 As Document
Dim oBM As Bookmark
Set oDoc1 = ThisD

HI Greg, Thanks again for helping on this, the code worked fine, but what
I
HI Greg, Thanks again for helping on this, the code worked fine, but what
I
was really after was the title of the source, rather than the actual text
e.g.
Bookmark 'insert32' = "Surname Field" etc. et

EggHeadCafe - Software Developer Portal of Choice
Visual Basic.NET and the .NET Platform [aPress]
http://www.eggheadcafe.com/tutorial...912-35144a12f26e/visual-basicnet-and-the.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top