Hello,

I've encountered strange bookmark behaviour.

The code is in C# but it should not matter:

// myWordApp variable points to the Application object
// myBookmark variable points to a bookmark.
myBookmark.Select();
Word.Selection selection =3D myWordApp.ActiveWindow.Selection;
selection.Text =3D "\xD6";

So far so good, but if I do:

selection.Font.Name =3D "Wingdings";

or

selection.InsertParagraphAfter();

The bookmark disappears.

Can anyone explain what's going on and how to overcome this issue?

Thanks,
Alex.

--=20
Address email to user "response" at domain "alexoren" with suffix "com"

Re: Disappearing bookmarks - nevermind... by Alex

Alex
Mon Apr 11 23:10:17 CDT 2005

Sorry, a correction - the bookmark disappears after changing the text.

// myWordApp variable points to the Application object
// myBookmark variable points to a bookmark.
myBookmark.Select();
Word.Selection selection =3D myWordApp.ActiveWindow.Selection;
selection.Text =3D "\xD6"; // the bookmark disappears.

Anyway, found the answer:
http://word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm

Thanks,
Alex.

--=20
Address email to user "response" at domain "alexoren" with suffix "com"

Excuse me, how do I post??? by papagru

papagru
Mon Apr 11 23:57:02 CDT 2005

I apologize for this stupid way to break in but I can't seem to post the
civilized way. When I click on new, the posting screen says I have not put
in my profile, but I have.
What am I doing wrong?
papagru



Re: Excuse me, how do I post??? by Helmut

Helmut
Tue Apr 12 01:36:57 CDT 2005

Hi,

at work I am using
http://communities.microsoft.com/newsgroups/default.asp?
icp=Prod_Office&sLCID=US&newsgroup=microsoft.public.word.vb
a.general

and there are no questions for profiles or whatsoever.


Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000


Re: Disappearing bookmarks by Word

Word
Tue Apr 12 07:44:18 CDT 2005

G'day "Alex" <inssup35@online.nospam>,

Don't select the bookmark, work with the bookmark's range. Anyway,
this is a known issue, the easiest way is to re-make the bookmark on
your new range.

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Alex reckoned:

>Hello,
>
>I've encountered strange bookmark behaviour.
>
>The code is in C# but it should not matter:
>
> // myWordApp variable points to the Application object
> // myBookmark variable points to a bookmark.
> myBookmark.Select();
> Word.Selection selection = myWordApp.ActiveWindow.Selection;
> selection.Text = "\xD6";
>
>So far so good, but if I do:
>
> selection.Font.Name = "Wingdings";
>
>or
>
> selection.InsertParagraphAfter();
>
>The bookmark disappears.
>
>Can anyone explain what's going on and how to overcome this issue?
>
>Thanks,
>Alex.


Re: Disappearing bookmarks by Alex

Alex
Fri Apr 29 20:30:15 CDT 2005

Hello Steve,

"Word Heretic" <myfullname@tpg.com.au> wrote in message =
news:gjgn51p629kdtfkbmvqkicqoui71r6u9mv@4ax.com...
> G'day "Alex" <inssup35@online.nospam>,
>=20
> Don't select the bookmark, work with the bookmark's range. Anyway,
> this is a known issue, the easiest way is to re-make the bookmark on
> your new range.

The reason that I select the bookmark is because this code is a special =
case of an operation that works with the current selection.

So I have Func() { /* do something with the current selection */ }
and I reuse it by selecting the bookmark, calling Func() and doing some =
bookmark-specific stuff later.


Best wishes,
Alex.

--=20
Address email to user "response" at domain "alexoren" with suffix "com"

Re: Disappearing bookmarks by Word

Word
Tue May 03 21:41:37 CDT 2005

G'day "Alex" <inssup35@online.nospam>,

Change that func to use a range. When you need to call it from
selection (avoided where possible) call it with Selection.Range

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Alex reckoned:

>Hello Steve,
>
>"Word Heretic" <myfullname@tpg.com.au> wrote in message news:gjgn51p629kdtfkbmvqkicqoui71r6u9mv@4ax.com...
>> G'day "Alex" <inssup35@online.nospam>,
>>
>> Don't select the bookmark, work with the bookmark's range. Anyway,
>> this is a known issue, the easiest way is to re-make the bookmark on
>> your new range.
>
>The reason that I select the bookmark is because this code is a special case of an operation that works with the current selection.
>
>So I have Func() { /* do something with the current selection */ }
>and I reuse it by selecting the bookmark, calling Func() and doing some bookmark-specific stuff later.
>
>
>Best wishes,
>Alex.


Re: Disappearing bookmarks by Alex

Alex
Wed May 04 10:33:40 CDT 2005

Hello Steve,

"Word Heretic" <myfullname@tpg.com.au> wrote in message =
news:6idg71dhs2i5uvq2ckm20vaqd8aem0v0eb@4ax.com...
> Change that func to use a range. When you need to call it from
> selection (avoided where possible) call it with Selection.Range

Refactoring. Good idea.


Re: Disappearing bookmarks by Word

Word
Thu May 05 20:44:19 CDT 2005

G'day "Alex" <inssup35@online.nospam>,

The term - refactoring - had me confused a few months ago as to what
the hell it was. Then I discovered it was basically what I had already
written a book about - optimising and cleaning up yer code :-)

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Alex reckoned:

>Hello Steve,
>
>"Word Heretic" <myfullname@tpg.com.au> wrote in message news:6idg71dhs2i5uvq2ckm20vaqd8aem0v0eb@4ax.com...
>> Change that func to use a range. When you need to call it from
>> selection (avoided where possible) call it with Selection.Range
>
>Refactoring. Good idea.