culling data to modify autotext...

K

Kalzin

Ok, so I have one part of a macro/script to insert entries into a wor
document is a line-by-line format

Code
-------------------

Dim p As Paragraph, r As Range, s As Strin
For Each p In ActiveDocument.Paragraph
'Skip empty pgphs, like the one that often finishes a doc
If Len(p.Range) 2 Then GoTo nexton
Set r = p.Rang
r.MoveEnd wdCharacter, -
s = Left(r.Text, 32
ThisDocument.AttachedTemplate.AutoTextEntries.Add Name:=s, Range:=
nextone
Next
MsgBox "Done

-------------------

This works to make the entries but does not allow me to create th
value... ie



will make three entries with A = A B = B and so on. what i need it to d
is take it like so

ExhibitA (hyper-linked

ExhibitB (hyper-linked
so that whatever I put there (the lines can change to other item
depending on the case structure) and create autotext with the 1st lin
being the name of the Auto-text and the 2nd line being the "value" o
the auto-text. I'm a little stuck here and it seems as if I'm close bu
not close enough. This is for Word 2003; can anyone help
 
K

Kalzin

Ok, I have found the code required to perform the action I need to i
do. there is a bit of a hang-up though as I need to tell VB to rea
every other paragraph.

Here is the 2 sets of code that need to be combined:
add data:

Code
-------------------

Dim p As Paragraph, r As Range, s As String
For Each p In ActiveDocument.Paragraphs
'Skip empty pgphs, like the one that often finishes a doc!
If Len(p.Range) 2 Then GoTo nextone
Set r = p.Range
r.MoveEnd wdCharacter, -1
s = Left(r.Text, 32)
ThisDocument.AttachedTemplate.AutoTextEntries.Add Name:=s, Range:=r
nextone:
Next p
MsgBox "Done"

-------------------


modifying the value of the auto-text:

Code
-------------------

ThisDocument.AttachedTemplate.AutoTextEntries("cName").Value = _ "Input from line 2 goes here"

-------------------


so essentially this would result in:

Code
-------------------

Dim p As Paragraph, r As Range, s As String, v As String
For Each p In ActiveDocument.Paragraphs
'Skip empty pgphs, like the one that often finishes a doc!
If Len(p.Range) 2 Then GoTo nextone
Set r = p.Range
r.MoveEnd wdCharacter, -1
s = Left(r.Text, 32)
?? Next p
?? v= ??
ThisDocument.AttachedTemplate.AutoTextEntries.Add Name:=s, Range:=r, Value:=v
nextone:
Next p
MsgBox "Done"

-------------------


I'd like to know if this would effectively do what I Need.
the ?? denotes where I need assistance. so would "Next p" (with ?
marks) be the proper way to have it move to the next paragraph befor
starting over? and if so what would I set the "v=" to if I want it t
store the entire paragraph to the "v" variable?

thanks
 

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