That's because a Bookmark CANNOT occur in a running header :-)
A bookmark must be on a "page". A running header is on multiple pages, so
the bookmark field cannot function.
Tell us what you are trying to do and we'll suggest a better method. I
suspect you are looking for a StyleREF field or a DocumentProperty field.
Cheers
On 11/11/09 10:08 PM, in article 59bab...@webcrossing.JaKIaxP2ac0,
"David_...@officeformac.com" <David_...@officeformac.com> wrote:
> Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel
> I have a bookmark in the header of a word document. I am trying to write some
> applescript to update the contents of the bookmark (which automatically
> deletes the bookmark) and then re-create the bookmark so that I am able to run
> the script multiple times on the one document.
>
> My problem is that I have been unable to find a way of creating a bookmark in
> the header.
>
> I have found the following code which is meant to replace the content of a
> bookmark and then re-create it. The code works fine within the main body of
> the document but I am unable to get it to work in the header.
>
> Any suggestions?
>
> =====================
>
> tell application "Microsoft Word"
>
> set bmRange to text object of bookmark "myBookmark" of active document
>
> set bmStart to bmRange's start of content
>
> set content of bmRange to "Inserted Text"
>
> set bmEnd to bmStart + (count "Inserted Text")
>
> make new bookmark at active document with properties {name:"myBookmark",
> start of bookmark:bmStart, end of bookmark:bmEnd}
>
> end tell
--
This email is my business email -- Please do not email me about forum
matters unless you intend to pay!
John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. | Ph: +61 (0)4 1209 1410
+61 4 1209 1410, mailto:jo...@mcghie.name
http://www.mactech.com/vba-transition-guide/index-041.html
or perhaps some intermediary. Or perhaps /they/ lifted their code from
elsewhere?
2. That said, from the Word 2004/VBA point of view, there's actually no
problem doing what you want to do as far as the product or the object
model is concerned - for example, in VBA you can do
Sub replacemybm1()
Dim rng As Word.Range
For Each rng In ActiveDocument.StoryRanges
If rng.Bookmarks.Count > 0 Then
Dim lngStart As Long
lngStart = rng.Bookmarks(1).Start
rng.Bookmarks(1).Range.Text = "replacement text"
Dim lngEnd As Long
lngEnd = lngStart + Len("replacement text")
rng.SetRange lngStart, lngEnd
rng.Bookmarks.Add "myBookmark", rng
End If
Next
End Sub
or
Sub replacemybm2()
Dim rng As Word.Range
Set rng = ActiveDocument.StoryRanges(7)
Dim lngStart As Long
lngStart = rng.Bookmarks(1).Start
rng.Bookmarks(1).Range.Text = "replacement text"
Dim lngEnd As Long
lngEnd = lngStart + Len("replacement text")
rng.SetRange lngStart, lngEnd
rng.Bookmarks.Add "myBookmark", rng
Set rng = Nothing
End Sub
The question is whether Applescript+the Word Applescript dictionary lets
you do what you want. Not being an Applescript person, the best I can do
is have a further look.
Peter Jamieson
Sorry, so far I haven't been able to find any way to do this.
Peter Jamieson
> (5) This script needs to be run multiple times. This is because a
> document can be created based on an existing document.
Peter Jamieson
Sounds like you're using something like ProjectWise.
There should be a module available in the document management system that
automatically populates the Document Properties (the metadata stored in the
document) with the information you want. There certainly is in ProjectWise,
and in Documentum.
Then you merely have to insert the document properties as fields in the text
and the information will populate automatically each time the document is
retrieved.
That's how we did it in RioTinto (ProjectWise, Documentum) and in
Commonwealth Bank (Documentum).
Most of the document properties you will need already exist in the Built-In
Document Properties (although some are not instantiated until you populate
them). But you can create as many more as you wish.
They key point I am making is that you can then avoid using bookmarks: you
simply insert "fields" and Word will automatically populate them for you.
Don't forget to "Update Fields" before saving the document :-)
I do wish these document management system vendors would take a look at how
Word actually operates before creating their vapourware that adds massive
costs to the implementation because they missed the point :-)
Hope this helps
On 25/11/09 9:05 PM, in article 59bab...@webcrossing.JaKIaxP2ac0,
"David_...@officeformac.com" <David_...@officeformac.com> wrote:
--
The email below is my business email -- Please do not email me about forum
matters unless I ask you to; or unless you intend to pay!