Edit word footer bookmark

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a word template. There is a footer bookmark called "thypk" on it.

I want to reach and edit this bookmark from asp code.

If objDoc.Bookmarks.Exists("thypk") = True Then
objDoc.Bookmarks("thypk").Select
objWord.Selection.Text = 'Success'

End If

I got this example from micrsoft side but It does not work.
here is the link :
http://support.microsoft.com/?kbid=212408

How can I edit word footer bookmark from asp code?

Thanks in advance

Metin
 
Are you sure that objDoc is really pointing to a document? Why change from
objDoc to objWord

--
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
 
Yes I am sure. I have a templeate which has a lot of bookmarks. I can reach
all bookmarks not in footer and header,if a bookmark is in the footer/header
I can not edit it.

Please look at the following my code script :

Set objWord = Server.CreateObject("word.application")
templatePath = Server.MapPath("..\") & "\DATA\templates\maintemp.dot"
Set objDoc = objWord.Documents.Add(templatePath)
objDoc.Activate
objDoc.Bookmarks("bookmark1").Select
objWord.Selection.Text = txtNumber


"Doug Robbins - Word MVP":
 
Does it work if you use a range object instead of working with a
selection? For example:

objDoc.Bookmarks("bookmark1").Range.Text = txtNumber

Note also that when you are setting the text of the selection, you are
actually deleting the bookmark (which could be a source of trouble). See
http://word.mvps.org/faqs/macrosvba/InsertingTextAtBookmark.htm for a
work-around.

--
Stefan Blom
Microsoft Word MVP


in message
 
It does not work to use range object.

can you check that it is really working?

or can you send me some asp code script. Maybe I am doing something wrong.

objDoc.Bookmarks("bookmark1").Range.Text = txtNumber

Bookmark will be in the footer.
 
There is no need to select a bookmark to insert something into it. In fact,
it is better not to.

The following vba code works, inserting the word "Hello" into a bookmark in
the footer of the active document.

Dim objDoc As Document
Set objDoc = ActiveDocument
objDoc.Bookmarks("test").Range.Text = "Hello"

If that doesn't work, insert

MsgBox txtNumber

into your code and make sure that there is something to be inserted.

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

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

Back
Top