Form Initialization

P

Patrick C. Simonds

I want to populate my UserForm with the contents of a document. I would like
to have something like what is below. Any ideas?

TextBox1.Text = Bookmark "LastName"
 
J

Jay Freedman

I want to populate my UserForm with the contents of a document. I would like
to have something like what is below. Any ideas?

TextBox1.Text = Bookmark "LastName"

TextBox1.Text = ActiveDocument.Bookmarks("LastName").Range.Text

Also, it's worthwhile either to use the construction

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

or to use the line

On Error Resume Next

or something similar to trap the error if the bookmark doesn't exist.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
J

Jay Freedman

What specific line is highlighted when that error occurs? Is this code in
the UserForm_Initialize() procedure? Is the control mentioned in the code
(TextBox1) actually in the userform, with that exact name?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top