Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Retaining Bookmarks in Autotext Macros

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mickey - 30 Oct 2007 19:58 GMT
I created a macro (with the wonderful help of Stefan Blom) that calls an
autotext (Smokey) in the header of each section of the document.  I basically
added bookmarks to a header and made it an autotext.  Problem is that the
first header loses the bookmarks after the next header is populated.  Any
suggestions on how to have all section headers retain the bookmarks that are
in the autotext???  Is there a better way that includes code that I could
have created the autotext???

Thanks,
Mickey
Tony Jollans - 30 Oct 2007 21:09 GMT
Bookmarks must have unique names. If you add a bookmark which has a
duplicate bookmark name, the previously existing one will be deleted. If you
have the bookmark in an Autotext entry then it will only be retianed in the
latest insertion. Basically you can't add bookmarks that way and must add
each individually after inserting the autotext.

Signature

Enjoy,
Tony

>I created a macro (with the wonderful help of Stefan Blom) that calls an
> autotext (Smokey) in the header of each section of the document.  I
[quoted text clipped - 8 lines]
> Thanks,
> Mickey
Mickey - 01 Nov 2007 01:27 GMT
Thanks Tony.  Do you know if it's possible to write another macro that can
update the headers (that lost the original bookmark) with a cross reference
to the bookmark?

Thanks,
Mickey

> Bookmarks must have unique names. If you add a bookmark which has a
> duplicate bookmark name, the previously existing one will be deleted. If you
[quoted text clipped - 14 lines]
> > Thanks,
> > Mickey
Tony Jollans - 01 Nov 2007 11:55 GMT
Why not just have two autotexts - one with the bookmark and one with a cross
reference?

Signature

Enjoy,
Tony

> Thanks Tony.  Do you know if it's possible to write another macro that can
> update the headers (that lost the original bookmark) with a cross
[quoted text clipped - 28 lines]
>> > Thanks,
>> > Mickey
Mickey - 01 Nov 2007 13:29 GMT
How would I code it to put one autotext in the first header and the other
autotext with the cross-reference in the subsequent headers.  Do you know the
code for cross-references?

Thanks so much for your help and time.

> Why not just have two autotexts - one with the bookmark and one with a cross
> reference?
[quoted text clipped - 31 lines]
> >> > Thanks,
> >> > Mickey
Tony Jollans - 01 Nov 2007 21:24 GMT
How are you coding it now? How many (different) headers have you got - in
fact, thinking about it, why have you got lots of different headers at all
if you want the same content in each?

You don't need code for the cross reference - just create it (manually) and
save as an autotext in the same way you have (presumably) done for your
bookmark.

Signature

Enjoy,
Tony

> How would I code it to put one autotext in the first header and the other
> autotext with the cross-reference in the subsequent headers.  Do you know
[quoted text clipped - 45 lines]
>> >> > Thanks,
>> >> > Mickey
Tony Jollans - 01 Nov 2007 22:12 GMT
I've just realised you're running two threads with this problem - it must be
as confusing for you as it is for me.

If you have two different Autotexts - Smokey and Smokey2, say - one with a
bookmark and one with a cross-reference to it, you should be able to change
Stefan's code along these lines:

Sub AddToMainHeader2()
Dim r As Range
Dim s As Section

For Each s In ActiveDocument.Sections
Set r = s.Headers(wdHeaderFooterPrimary) _
   .Range.Paragraphs(1).Range

With r
   .ParagraphFormat.TabStops.ClearAll
   .ParagraphFormat.TabStops(InchesToPoints(1.25)) _
   .Alignment = wdAlignTabLeft
   .ParagraphFormat.TabStops(InchesToPoints(6.5)) _
   .Alignment = wdAlignTabRight

   .Collapse wdCollapseStart
   .InsertAfter vbTab
   .InsertAfter vbTab
   .Collapse wdCollapseEnd

   If s.Index = 1 then
       NormalTemplate.AutoTextEntries("Smokey").Insert _
       Where:=r, RichText:=True
   Else
       NormalTemplate.AutoTextEntries("Smokey2").Insert _
       Where:=r, RichText:=True
   End If

End With
Next s

End Sub

Signature

Enjoy,
Tony

> How would I code it to put one autotext in the first header and the other
> autotext with the cross-reference in the subsequent headers.  Do you know
[quoted text clipped - 45 lines]
>> >> > Thanks,
>> >> > Mickey
Mickey - 02 Nov 2007 01:55 GMT
Works Great.  Thank you so much.  I can't begin to express how grateful I am.
Again, thank you.

Mickey

> I've just realised you're running two threads with this problem - it must be
> as confusing for you as it is for me.
[quoted text clipped - 85 lines]
> >> >> > Thanks,
> >> >> > Mickey
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.