I don't know what I need!

M

mortgage man

I am trying to set up a template document that will prompt me the choice of
several paragraphs and then insert one of them into the document before
prompting me for more choices depending on the outcome of the first option.
I have no idea whether I need a macro or whatever. I've tried looking in the
help file but without knowing what I want to do is called it's very difficult
to find anything relevant!
 
E

Ed

Well, since no one else has ventured here, I'll give you what came to my
mind. I'm not saying it's good, but it might get you started.

First, map out all your choices. If you have a first choice of three
paragraphs, and each of these gives you a choice of three paragraphs, and
each of those gives you three paragraphs - in three steps, you have 27
different combinations! This could very quickly get out of control. On the
other hand, if you have even only 10 possible combinations, you are farther
ahead. If you've got only the 10 choices, then set up a series of option
buttons on a form that will lead you to your proper choice.

If you've got the paragraph, tree, then my idea was to set up your template
with bookmarks, and populate each bookmark with your paragraph choices. For
instance, your first bookmark, perhaps named "1p1" (first paragraph, first
choice) has all the paragraphs you would choose from for your first
selection. Your form would allow you to select (option buttons?) which
paragraph by incrementing through the Paragraphs of the Bookmark Range.
Select Option Button 1, it shows you 1p1, para1 in a text box; OB2 will show
para2; etc. A Command Button will load the selected paragraph. It will
also collect the number of the paragraph.

So you loaded paragraph 3 - now the code find the bookmark named "2p3"
(second paragraph, with the third paragraph chosen before; had you chosen
the first paragraph, it would look for bookmark 2p1). And increments
through those paragraphs, allowing you to choose and load and select the
next one, etc.

As you can see, this can quickly get very hairy, and I'm not saying I've got
the best handle on how to do it. But maybe it'll get you started - even if
it's away from this, you'll have a direction! 8>)

Ed
 
M

mortgage man

Thanks Ed. I'm not sure I fully understand your response but I'll have a
fiddle and hopefully get there. I do have the paragraph tree already.

Simon
 
D

David Sisson

In addition to Ed's suggestions:

Look into AutoText and AutoCorrect.

This is the reverse of Ed's suggestion, but this might work. Put all
the paragraphs in one document. Name each range with a bookmark.
Popup a userform with the list of bookmarks either in a dropdown or
with option buttons. When confirming the choices, let the event/macro
delete all the bookmarks(text) you don't want.

Or you can put all you text into the userform and pick the paragraphs
through a couple of dropdowns. You can program dropdown2 to only show
the choices that go with Paragraph 1, etc. One drawback to this method
is if your text changes occasionally, it's a little harder to edit.
 
C

Chuck

You do need a macro, although I suppose it could be done with ASK and IF
fields. You should consider using AutoText to store your boilerplate
paragraphs.

You could use a macro to call up a userform where you can guide your user
through all the steps they need to create a document in one place - once
they've made the appropriate choices, if they click OK your code can build
the document using the boilerplate AutoText.

You're going to need to get to grips with drop down fields on userforms (to
present the user with lists of boilerplate paragraph choices), how to
populate drop downs based on the values in other fields (if they choose x in
one field, their choices are restricted to y and z in another), using code to
retrieve autotext entries and code for navigating around a document using
bookmarks. All of those topics are covered in VBE help (more or less
helpfully). Another good resource is the MVPS website: http://word.mvps.org/

Let me know if that's confusing...
 
E

Ed

Simon:

This might get you going. Pull up a document and select several paragraphs
(or copy several paragraphs to a blank document, because you don't want to
get into the habit of experimenting on important documents! Don't ask me
how I figured that out!!). Then copy the following macro into a module.
The macro will set the selected paragraphs into a bookmark, then access the
range of the bookmark to iterate through the paragraphs, giving you the
number and text of each paragraph. Just a demo. (BTW, I'm using Word 2000.
This should work with 98-XP, as far as I know.)

Ed

Sub Par2Bkmk()

Dim doc As Document
Dim bk As Bookmark
Dim par As Paragraph
Dim x As Long

Set doc = ActiveDocument

StartHere:
If Selection.Characters.Count < 2 Then
MsgBox "Select something"
GoTo StartHere
End If

Set bk = doc.Bookmarks.Add(Name:="bkmk1", Range:=Selection.Range)

For x = 1 To bk.Range.Paragraphs.Count
Set par = bk.Range.Paragraphs(x)
MsgBox "This is paragraph number" & x & ". It says:" _
& vbCr & par.Range.Text
Next x

End Sub
 

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