Dave
Wed Aug 13 07:26:41 CDT 2003
Hi Camilla,
Using the Range object, as Martin suggested, only works if you have
enclosing bookmarks. However, it's clear from your description that you have
a placeholder bookmark. Take a look at the article "Working with Bookmarks
in VBA" at
http://www.mvps.org/word/FAQs/MacrosVBA/WorkWithBookmarks.htm.
After that have a look at the article "Inserting text at a bookmark without
deleting the bookmark" at
http://www.mvps.org/word/FAQs/MacrosVBA/InsertingTextAtBookmark.htm.
After you create an enclosing bookmark in your template, you can use the
methods described in the second article.
HTH
"Camilla" <camilla@falckstockholm.com> wrote in message
news:05a801c36191$398a6830$a001280a@phx.gbl...
Sorry, but I don't understand exactly how I can use your
example in this code. Every Autotextentries has their own
adress, phone etc and teh Select case make choice which
one will be inserted.
ActiveDocument.Bookmarks("dn_Adress").Select
SaveSetting "DN", "Configuration", "DefaultAdress",
Me.CombAdresser.Text
Select Case Me.CombAdresser.Text
Case "Falun" '/Falun
ActiveDocument.AttachedTemplate.AutoTextEntries
("dn_Adr_Falun").Insert Selection.Range, True
Case "Gävle" '/Gävle
ActiveDocument.AttachedTemplate.AutoTextEntries
("dn_Adr_Gävle").Insert Selection.Range, True.
Regards Camilla
>-----Original Message-----
>Hi Camilla
>
>it is easier to use the Range Object, you don't have to
open the header
>nor select the textbox...
>Because the bookmark is redefind at the end the existing
text gets
>replaced.
>
>Dim rng As Range
>Set rng = ActiveDocument.Bookmarks("dn_Adress").Range
>With rng
> .Delete
> .InsertAfter "dn_Adr_" & Me.CombAdresser.Text
> .InsertAutoText
>End With
>ActiveDocument.Bookmarks.Add "dn_Adress", rng
>
>
>hth, Martin
>
>In article <047f01c36122$1dc44450$a501280a@phx.gbl>,
>camilla@falckstockholm.com says...
>> I have a template for 20 different localoffice. The
user
>> choose in a form which office they belong and then
click
>> OK and it will be correct inserted in the pagehader. I
>> have all officeaddress as autotext, the code choose
>> correct address and put it in the textbox with this
code:
>> ActiveDocument.Bookmarks("dn_Adress").Select
>> SaveSetting "DN", "Configuration", "DefaultAdress",
>> Me.CombAdresser.Text
>> Select Case Me.CombAdresser.Text
>> Case "Falun" '/Falun
>>
ActiveDocument.AttachedTemplate.AutoTextEntries
>> ("dn_Adr_Falun").Insert Selection.Range, True
>> Case "Gävle" '/Gävle
>>
ActiveDocument.AttachedTemplate.AutoTextEntries
>> ("dn_Adr_Gävle").Insert Selection.Range, True.
>>
>> The bookmark is placed in pageheader in a textbox.
>> My very big problem is that I must reload the userform
to
>> let the user change the address and when I do that will
>> the new officeaddress appear after the first one, I
need
>> help how I can select and replace the text with the new
>> address. Can anyone help me with this?
>>
>> Thanks for any help
>> Camilla
>>
>>
>
>--
>Martin Sägesser
>www.sibs.ch
>.
>