Help Newby with VB 
Author Message
 Help Newby with VB

I Have a word document that I would like to add VB code that will have a
user form that will prompt me for input and than put the information in the
right places on my word document. I tried to experiment but I can't figure
it out , please help. If you can tell me the basics I think I can figure the
rest out. Thanks


Sat, 26 Oct 2002 03:00:00 GMT  
 Help Newby with VB


Quote:
> I Have a word document that I would like to add VB code that will have a
> user form that will prompt me for input and than put the information in the
> right places on my word document. I tried to experiment but I can't figure
> it out , please help. If you can tell me the basics I think I can figure the
> rest out. Thanks

Hi,

I think it's best to take this one step at the time. What I understand
is, you want to click on a button, after which a fill-in form appears on
the screen, allowing you to input some data?
This data will then be put into a document? Is all this correct?

Richard

--
The fact that you aren't paranoid doesn't
necessarily mean nobody is following you!

Sent via Deja.com http://www.deja.com/
Before you buy.



Sun, 27 Oct 2002 03:00:00 GMT  
 Help Newby with VB
Hi Tony,

What you really need to do is create a template from which you create the
documents
in which you want this facility.

This example shows how you would deal with two pieces of information
that you want to put into the document. By adding more of those steps, you
can
deal with more variables

1. Create two bookmarks in your template named "Text1" and "Text2" (add
additional bookmarks for each piece of data)
2. Go to the Visual Basic Editor (Tools>Macro>Visual Basic Editor)
3. With the Template selected in the Project Explorer, Insert a UserForm
(I am assuming that it will be UserForm1)
4. In the UserForm, insert 2 text boxes - assumed to be TextBox1 and
TextBox2
5. Dimension them as required for the text that you intend to be inserted
into them
6. Add any labels that you want to have on the form to assist the user
7. In the UserForm, insert a CommandButton - assumed to be CommandButton1
8. Right Click on the CommandButton and click on View Code
9. Enter the following code:

Private Sub CommandButton1_Click()
With ActiveDocument
.Bookmarks("Text1").Range.InsertBefore TextBox1
.Bookmarks("Text2").Range.InsertBefore TextBox2
End With
UserForm1.Hide
End Sub

(Repeat the lines With ActiveDocument.Bookmarks and .InsertBefore for each
bookmark. Similarly, you can go to a second bookmark and insert the same
piece of data.)

12. Close the Visual Basic Editor
13 From the Tools Menu select Macro, then Macros, then with the Template
selected in the "Macros in:" box, type the name autonew in the "Macro name:"
box and click the Create button.
14 Enter the following command in the module screen:
UserForm1.Show
15. Exit from the Visual Basic Editor and save your template.

When you create a new document from the template, the autonew macro opens
the user form for the user to input data, then when the command button is
clicked, the code associated with that button moves the selection to each of
the bookmarks in the document and inserts the relevant piece of data into
them.

Hope this helps,
Doug Robbins - Word MVP
Please post any follow-up to the Newsgroups so that others may benefit
therefrom or contribute thereto.

Quote:
> I Have a word document that I would like to add VB code that will have a
> user form that will prompt me for input and than put the information in
the
> right places on my word document. I tried to experiment but I can't figure
> it out , please help. If you can tell me the basics I think I can figure
the
> rest out. Thanks



Sun, 27 Oct 2002 03:00:00 GMT  
 Help Newby with VB
I want the user to enter the info on the form. Then after all the info is
in., the info should goto the appropriate areas of the word document.
Quote:



> > I Have a word document that I would like to add VB code that will have a
> > user form that will prompt me for input and than put the information in
the
> > right places on my word document. I tried to experiment but I can't
figure
> > it out , please help. If you can tell me the basics I think I can figure
the
> > rest out. Thanks

> Hi,

> I think it's best to take this one step at the time. What I understand
> is, you want to click on a button, after which a fill-in form appears on
> the screen, allowing you to input some data?
> This data will then be put into a document? Is all this correct?

> Richard

> --
> The fact that you aren't paranoid doesn't
> necessarily mean nobody is following you!

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sun, 27 Oct 2002 03:00:00 GMT  
 Help Newby with VB
Why do you want to code this in VB? Is there a reason to not use a Form
template that simply let's the user type the information in text fields
which are also bookmarks?

This would be a lot simpler unless your needs exceed the abilities of Word's
forms.
Check the help topic for "Create a Form" for info. You would be creating an
"online form" even if what you plan on is something that is printed out
rather than just used on the computer.

--
 --------- --------- --------- --------- --------- ---------
Charles Kenyon (Balance Check) from the shores of that
 inland sea known as Lake Michigan.

Home page: <URL: http://user.cybrzn.com/~kenyonck/ >

 --------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.


Quote:
> I Have a word document that I would like to add VB code that will have a
> user form that will prompt me for input and than put the information in
the
> right places on my word document. I tried to experiment but I can't figure
> it out , please help. If you can tell me the basics I think I can figure
the
> rest out. Thanks



Tue, 05 Nov 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Newby help

2. Newby help!!!!!

3. Newby needs help

4. NEWBY strikes again - need some help on processng text files

5. Newby requires your help

6. UserControl-newby needs your help

7. Newby - Help Req: How to Uncheck?

8. Help a newby with finding the time between events

9. Newby Help please?

10. newby needs help

11. Newby needs help

12. NEWBY HELP ME PLESE

 

 
Powered by phpBB® Forum Software