Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word User Form - Generate doc based on Drop Down Choice 1

Status
Not open for further replies.

rhoneyfi

MIS
Apr 8, 2002
200
US
Hello,
I am new to the world of User Forms. Here's what I want to do:

1)A user enters in a clients name/address in a text box
2) Then from a drop down list, they choose if the client's business is a Corporation, LLC, or Partnership
3) They then click a button that says "Generate Letter"

There are 3 types of letters based on the clients business type...so the letter to a Corporation would be differnt that the letter we would send to an LLC,etc...

How would I go about doing this...is it even possible???
 
Oh yes it is very possible.

There are a a couple of ways to design this, and how to implement it depends on which way you end up going.

First, the UserForm. If you have a list of clients, then perhaps you may want to have the client list as a drop down as well. You mention client name, and address into one textbox. I would do them separately, but you certainly could parse the address out if you wanted to. However, if you have a solid list, have the choice made from a drop down.

The dropdown with the buisiness type (Corp., LLC etc) is no problem. Just make a dropdown with those items.

The "Generate Letter" button will action the letters depending on how you have it set up.

The Letters
[ul][li]all the letter types in ONE document[/li]
[li]separate letter documents[/li]
[/ul]

There are advantages and disadvantages to either way. Personally, I lean towards having everything in ONE document. In other words, there is ONE document, with all three letter types in it.

The userform comes up with the Document_Open event. The user enters the name and address, chooses the letter type, and clicks "generate"

The UserForm closes, goes into the document, finds the parts that are NOT relevant and removes them, leaving the document with the relevant parts. Fills in the name and address into the document, along with any other information you want to collect.

Some practical details?

Write the whole document. Select the entire portion of the document that is "Corporation" type. Select Insert > Bookmark. Give it the name Corporation (or if you are fine with a shorter name - I do - just name it "corp"), and select OK.

Select the entire portion for "LLC" type, and makr a bookmark for that. Repeat for "Partnership" What you have done is make a bookmark for the each of the letter types.

Now, back to the UserForm. The user enters the name/address, and selects LLC from the dropdown. On close - and this is just an example...you want to REMOVE the Corporation chunk, and the Partnership chunk, right? This can be done with two lines of code.

ActiveDocument.Bookmarks("Corporation").Range.Delete
ActiveDocument.Bookmarks("Partnership").Range.Delete

Bada bing, bada boom. Those chunks are gone, and you have the LLC chunk left.

For dumping in the name address etc., gosh, there are a number of ways to get the info in. Form fields, activex controls, or other bookmarks where you replace text with that info.

Hope this helps., but SURE what you are asking for is very very possible.

Gerry
 
Gerry,
Wow, thanks for all the great info. I'll give it a try.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top