Re: help with automating letter
- From: "Greg Maxey" <gmaxey@xxxxxxxx>
- Date: 21 Apr 2006 05:07:56 -0700
Colm,
Well without a database you are going to have to store the blah 1 and
blah 2 data either as another file or as AutoText. Then you are going
to need an autoopen macro that asks the questions or use a Userform
(preferred) see:
http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm
Then you will need to use a field or bookmark to mark the spot in the
document for data insertion.
Here is a small example. You create a pair of AutoText entries with
detailed instructions for doing what ever. For this example name them
goleft and goright. You create bookmark in the document where you want
the data to appear (call it Answer1). You create an autoopen macro
that asks the questions and inserts the appropriate text based on the
answer:
Sub AutoOpen()
Dim oDoc As Word.Document
Dim BMRange As Word.Range
Set oDoc = ActiveDocument
Set BMRange = oDoc.Bookmarks("Answer1").Range
If InputBox("Answer yes or no", "Question", "yes") = "yes" Then
BMRange.Text = oDoc.AttachedTemplate.AutoTextEntries("GoLeft").Value
oDoc.Bookmarks.Add "Answer1", BMRange
Else
BMRange.Text = oDoc.AttachedTemplate.AutoTextEntries("GoRight").Value
oDoc.Bookmarks.Add "Answer1", BMRange
End If
End Sub
.
- Prev by Date: Re: How to get data from txt file into table of word template thro
- Next by Date: Re: How to get data from txt file into table of word template thro
- Previous by thread: Re: Delete section breaks without using replace
- Next by thread: Re: help with automating letter
- Index(es):