Retrieving userform info into a document

J

Jason Logue

Hi, I currently have macro that that generates userforms for a
template. The user walks through each userform, enters text and
clicks Next. On a few of the windows, they will click another button
that is designed to retreive information from a bookmarked manual.
The first window that pops up displays the chapters. They select the
chapter with the text they want, and then the bookmarked sections are
displayed. When they click on the button for that section, the
adjacent textbox in the first userform is filled with this
information. They can then click Next on the bottom of the window to
move on.

I'd like to make the chapter/section retrieval windows available to
the client anywhere in the document. They could simply click on a
toolbar button and it would insert the text after the cursor.

The code for opening the chapter window, then section window and then
retrieving the information for a textbox goes like the following.
This is an example using Chapter1, Section 1.

Sub CommandButton1_Click()

Chapters1a.Show (this shows the list of chapters in the manual)

End Sub

'Then the user clicks on a chapter, in this instance chapter one.

Sub CommandButton1_Click()

Chapters1a.Hide(this hides the list of chapters)

Chapter1a.Show (this shows the chapter one window with the bookmarked
sections)

End Sub

'Then the user clicks on 1.1 (Chapter one, section one) to insert the
text in the textbox on the userform from where they clicked the first
Commandbutton1_click.

'This is the code under the 1.1 button.


Sub CommandButton1_Click()

' Call ButtonClick

Set source = Documents.Open("C:\Documents and Settings\Logue\My
Documents\Allied Title\exceptions\exceptions.doc")

(The above code sets the source as the Exceptions.doc, which is the
manual)

Userform3.TextBox8.Text = source.Bookmarks("Chapter1_1").Range

(The above code tells the text in bookmark Chapter1_1 to populate the
textbox in Userform3. I would like it to populate the location of the
cursor in the current document.)

Documents("C:\Documents and Settings\Logue\My Documents\Allied
Title\exceptions\exceptions.doc").Close SaveChanges = False

(The above code just closes the exceptions.doc)

Chapter1a.Hide

(The above code hides the section window.)

End Sub

TIA,
Jason
 
W

Word Heretic

G'day (e-mail address removed) (Jason Logue),

have a button on the menu, opens your userform, userform works on
selection... huh?


(e-mail address removed) (Jason Logue) was spinning this yarn:
Hi, I currently have macro that that generates userforms for a
template. The user walks through each userform, enters text and
clicks Next. On a few of the windows, they will click another button
that is designed to retreive information from a bookmarked manual.
The first window that pops up displays the chapters. They select the
chapter with the text they want, and then the bookmarked sections are
displayed. When they click on the button for that section, the
adjacent textbox in the first userform is filled with this
information. They can then click Next on the bottom of the window to
move on.

I'd like to make the chapter/section retrieval windows available to
the client anywhere in the document. They could simply click on a
toolbar button and it would insert the text after the cursor.

The code for opening the chapter window, then section window and then
retrieving the information for a textbox goes like the following.
This is an example using Chapter1, Section 1.

Sub CommandButton1_Click()

Chapters1a.Show (this shows the list of chapters in the manual)

End Sub

'Then the user clicks on a chapter, in this instance chapter one.

Sub CommandButton1_Click()

Chapters1a.Hide(this hides the list of chapters)

Chapter1a.Show (this shows the chapter one window with the bookmarked
sections)

End Sub

'Then the user clicks on 1.1 (Chapter one, section one) to insert the
text in the textbox on the userform from where they clicked the first
Commandbutton1_click.

'This is the code under the 1.1 button.


Sub CommandButton1_Click()

' Call ButtonClick

Set source = Documents.Open("C:\Documents and Settings\Logue\My
Documents\Allied Title\exceptions\exceptions.doc")

(The above code sets the source as the Exceptions.doc, which is the
manual)

Userform3.TextBox8.Text = source.Bookmarks("Chapter1_1").Range

(The above code tells the text in bookmark Chapter1_1 to populate the
textbox in Userform3. I would like it to populate the location of the
cursor in the current document.)

Documents("C:\Documents and Settings\Logue\My Documents\Allied
Title\exceptions\exceptions.doc").Close SaveChanges = False

(The above code just closes the exceptions.doc)

Chapter1a.Hide

(The above code hides the section window.)

End Sub

TIA,
Jason

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If my answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 

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

Similar Threads


Top