Can anyone tell me why the code below does not insert the text at
Bookmarks("LastName") into TextBox1?

Private Sub UserForm_Initialize()

'Places data in the userform text boxes if it exists on the spreadsheet

If ActiveDocument.Bookmarks.Exists("LastName") Then
TextBox1.Text = ActiveDocument.Bookmarks("LastName").Range.Text
End If

End Sub

Re: UserForm_Initialize problem by Patrick

Patrick
Sat Apr 14 12:57:39 CDT 2007

Sorry about the typo in the original post. This is in a Word document not a
spreadsheet.

"Patrick C. Simonds" <ordnance1@comcast.net> wrote in message
news:uwlUl3rfHHA.4872@TK2MSFTNGP03.phx.gbl...
> Can anyone tell me why the code below does not insert the text at
> Bookmarks("LastName") into TextBox1?
>
> Private Sub UserForm_Initialize()
>
> 'Places data in the userform text boxes if it exists on the spreadsheet
>
> If ActiveDocument.Bookmarks.Exists("LastName") Then
> TextBox1.Text = ActiveDocument.Bookmarks("LastName").Range.Text
> End If
>
> End Sub
>
>



Re: UserForm_Initialize problem by Helmut

Helmut
Sat Apr 14 15:40:26 CDT 2007

Hi Patrick,

you haven't got an excluding ][ bookmark by any chance?

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Re: UserForm_Initialize problem by Greg

Greg
Sat Apr 14 15:41:31 CDT 2007

It does here is the bookmark range encompasses the text you want
placed in the the textbox. Are you sure your bookmark spans the text
range?

On Apr 14, 1:57 pm, "Patrick C. Simonds" <ordnan...@comcast.net>
wrote:
> Sorry about the typo in the original post. This is in a Word document not a
> spreadsheet.
>
> "Patrick C. Simonds" <ordnan...@comcast.net> wrote in messagenews:uwlUl3rfHHA.4872@TK2MSFTNGP03.phx.gbl...
>
>
>
> > Can anyone tell me why the code below does not insert the text at
> > Bookmarks("LastName") into TextBox1?
>
> > Private Sub UserForm_Initialize()
>
> > 'Places data in the userform text boxes if it exists on the spreadsheet
>
> > If ActiveDocument.Bookmarks.Exists("LastName") Then
> > TextBox1.Text = ActiveDocument.Bookmarks("LastName").Range.Text
> > End If
>
> > End Sub- Hide quoted text -
>
> - Show quoted text -



Re: UserForm_Initialize problem by Patrick

Patrick
Sat Apr 14 16:19:35 CDT 2007

No I am sure it does not. I added the BookMark, how do I get it to encompass
the text? Do I need to have some sort of BookMark end?


"Greg Maxey" <gmaxey@gmail.com> wrote in message
news:1176583291.075866.306810@q75g2000hsh.googlegroups.com...
> It does here is the bookmark range encompasses the text you want
> placed in the the textbox. Are you sure your bookmark spans the text
> range?
>
> On Apr 14, 1:57 pm, "Patrick C. Simonds" <ordnan...@comcast.net>
> wrote:
>> Sorry about the typo in the original post. This is in a Word document not
>> a
>> spreadsheet.
>>
>> "Patrick C. Simonds" <ordnan...@comcast.net> wrote in
>> messagenews:uwlUl3rfHHA.4872@TK2MSFTNGP03.phx.gbl...
>>
>>
>>
>> > Can anyone tell me why the code below does not insert the text at
>> > Bookmarks("LastName") into TextBox1?
>>
>> > Private Sub UserForm_Initialize()
>>
>> > 'Places data in the userform text boxes if it exists on the spreadsheet
>>
>> > If ActiveDocument.Bookmarks.Exists("LastName") Then
>> > TextBox1.Text = ActiveDocument.Bookmarks("LastName").Range.Text
>> > End If
>>
>> > End Sub- Hide quoted text -
>>
>> - Show quoted text -
>
>



Re: UserForm_Initialize problem by Jay

Jay
Sat Apr 14 21:52:38 CDT 2007

If you're creating the bookmark manually, you must select the text
before you insert the bookmark.

If you're creating the bookmark from inside a macro, see
http://www.word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm.

One thing that's helpful is to go to Tools > Options > View and check
the box for Bookmarks. The ends of the bookmarks will then appear in
the text as gray square brackets (nonprinting characters).

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 14 Apr 2007 14:19:35 -0700, "Patrick C. Simonds"
<ordnance1@comcast.net> wrote:

>No I am sure it does not. I added the BookMark, how do I get it to encompass
>the text? Do I need to have some sort of BookMark end?
>
>
>"Greg Maxey" <gmaxey@gmail.com> wrote in message
>news:1176583291.075866.306810@q75g2000hsh.googlegroups.com...
>> It does here is the bookmark range encompasses the text you want
>> placed in the the textbox. Are you sure your bookmark spans the text
>> range?
>>
>> On Apr 14, 1:57 pm, "Patrick C. Simonds" <ordnan...@comcast.net>
>> wrote:
>>> Sorry about the typo in the original post. This is in a Word document not
>>> a
>>> spreadsheet.
>>>
>>> "Patrick C. Simonds" <ordnan...@comcast.net> wrote in
>>> messagenews:uwlUl3rfHHA.4872@TK2MSFTNGP03.phx.gbl...
>>>
>>>
>>>
>>> > Can anyone tell me why the code below does not insert the text at
>>> > Bookmarks("LastName") into TextBox1?
>>>
>>> > Private Sub UserForm_Initialize()
>>>
>>> > 'Places data in the userform text boxes if it exists on the spreadsheet
>>>
>>> > If ActiveDocument.Bookmarks.Exists("LastName") Then
>>> > TextBox1.Text = ActiveDocument.Bookmarks("LastName").Range.Text
>>> > End If
>>>
>>> > End Sub- Hide quoted text -
>>>
>>> - Show quoted text -
>>
>>
>

Re: UserForm_Initialize problem by Bear

Bear
Mon Apr 16 10:48:08 CDT 2007

In addition to Jay's comment, I also find it helpful to click Insert >
Bookmark, select the bookmark name, then click GoTo. This shows me that the
bookmark exists, and what it contains.

Bear