I have a template for 20 different localoffice. The user=20
choose in a form which office they belong and then click=20
OK and it will be correct inserted in the pagehader. I=20
have all officeaddress as autotext, the code choose=20
correct address and put it in the textbox with this code:
ActiveDocument.Bookmarks("dn_Adress").Select
SaveSetting "DN", "Configuration", "DefaultAdress",=20
Me.CombAdresser.Text
Select Case Me.CombAdresser.Text
Case "Falun" '/Falun
ActiveDocument.AttachedTemplate.AutoTextEntries
("dn_Adr_Falun").Insert Selection.Range, True
Case "G=E4vle" '/G=E4vle
ActiveDocument.AttachedTemplate.AutoTextEntries
("dn_Adr_G=E4vle").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=20
let the user change the address and when I do that will=20
the new officeaddress appear after the first one, I need=20
help how I can select and replace the text with the new=20
address. Can anyone help me with this?

Thanks for any help
Camilla

Re: VBA and bookmark in a textbox in header/footer by info

info
Wed Aug 13 01:38:33 CDT 2003

Hi Camilla

it is easier to use the Range Object, you don't have to open the header=20
nor select the textbox...
Because the bookmark is redefind at the end the existing text gets=20
replaced.

Dim rng As Range
Set rng =3D 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>,=20
camilla@falckstockholm.com says...
> I have a template for 20 different localoffice. The user=20
> choose in a form which office they belong and then click=20
> OK and it will be correct inserted in the pagehader. I=20
> have all officeaddress as autotext, the code choose=20
> correct address and put it in the textbox with this code:
> ActiveDocument.Bookmarks("dn_Adress").Select
> SaveSetting "DN", "Configuration", "DefaultAdress",=20
> Me.CombAdresser.Text
> Select Case Me.CombAdresser.Text
> Case "Falun" '/Falun
> ActiveDocument.AttachedTemplate.AutoTextEntries
> ("dn_Adr_Falun").Insert Selection.Range, True
> Case "G=E4vle" '/G=E4vle
> ActiveDocument.AttachedTemplate.AutoTextEntries
> ("dn_Adr_G=E4vle").Insert Selection.Range, True.
>=20
> The bookmark is placed in pageheader in a textbox.
> My very big problem is that I must reload the userform to=20
> let the user change the address and when I do that will=20
> the new officeaddress appear after the first one, I need=20
> help how I can select and replace the text with the new=20
> address. Can anyone help me with this?
>=20
> Thanks for any help
> Camilla
>=20
>=20

--=20
Martin S=E4gesser
www.sibs.ch

Re: VBA and bookmark in a textbox in header/footer by Camilla

Camilla
Wed Aug 13 06:51:25 CDT 2003

Sorry, but I don't understand exactly how I can use your=20
example in this code. Every Autotextentries has their own=20
adress, phone etc and teh Select case make choice which=20
one will be inserted.

ActiveDocument.Bookmarks("dn_Adress").Select
SaveSetting "DN", "Configuration", "DefaultAdress", =20
Me.CombAdresser.Text

Select Case Me.CombAdresser.Text

Case "Falun" '/Falun =20
ActiveDocument.AttachedTemplate.AutoTextEntries
("dn_Adr_Falun").Insert Selection.Range, True

Case "G=E4vle" '/G=E4vle =20
ActiveDocument.AttachedTemplate.AutoTextEntries
("dn_Adr_G=E4vle").Insert Selection.Range, True.
=20
Regards Camilla

>-----Original Message-----
>Hi Camilla
>
>it is easier to use the Range Object, you don't have to=20
open the header=20
>nor select the textbox...
>Because the bookmark is redefind at the end the existing=20
text gets=20
>replaced.
>
>Dim rng As Range
>Set rng =3D 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>,=20
>camilla@falckstockholm.com says...
>> I have a template for 20 different localoffice. The=20
user=20
>> choose in a form which office they belong and then=20
click=20
>> OK and it will be correct inserted in the pagehader. I=20
>> have all officeaddress as autotext, the code choose=20
>> correct address and put it in the textbox with this=20
code:
>> ActiveDocument.Bookmarks("dn_Adress").Select
>> SaveSetting "DN", "Configuration", "DefaultAdress",=20
>> Me.CombAdresser.Text
>> Select Case Me.CombAdresser.Text
>> Case "Falun" '/Falun
>> =20
ActiveDocument.AttachedTemplate.AutoTextEntries
>> ("dn_Adr_Falun").Insert Selection.Range, True
>> Case "G=E4vle" '/G=E4vle
>> =20
ActiveDocument.AttachedTemplate.AutoTextEntries
>> ("dn_Adr_G=E4vle").Insert Selection.Range, True.
>>=20
>> The bookmark is placed in pageheader in a textbox.
>> My very big problem is that I must reload the userform=20
to=20
>> let the user change the address and when I do that will=20
>> the new officeaddress appear after the first one, I=20
need=20
>> help how I can select and replace the text with the new=20
>> address. Can anyone help me with this?
>>=20
>> Thanks for any help
>> Camilla
>>=20
>>=20
>
>--=20
>Martin S=E4gesser
>www.sibs.ch
>.
>

Re: VBA and bookmark in a textbox in header/footer by Dave

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