
June 15th, 2012, 07:15 PM
|
|
Registered User
|
|
Join Date: Jun 2012
Posts: 2
Time spent in forums: 35 m 16 sec
Reputation Power: 0
|
|
VB for Word: Macro to Populate Auto-Text
Long story short: I need to be able to list data and have that data populate the Auto-Text in MS Word 2003 via VBS. So far I can manipulate the Auto-Text through the following code, but i need to to read 1 line and insert a Hypertext from a second line.
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"
This one acts line by line. I need One line (first line) to perform as above, I need a second line to be input into a different function. So from above I need to pass this through:
Code:
ThisDocument.AttachedTemplate.AutoTextEntries("cName").Value = _ "Input from line 2 goes here"
cName would pull the data in Line 1 ("s" in previous macro), the input part is Line 2.
goal:
ex1 is auto-text with a "value" of <a href="\\UNC\Path\Exhibit1.pdf">Exhibit 1</a>
I have no idea how to tell it to read line 1 as the first part of the code and then pull the name from 1st part and use it in 2nd part to add the value from the next "paragraph"... any ideas?
|