I want to make preparing a dotx template simple for a typist.
I say create the letter and format the font colour of all the variable bits to RED.
Overtype the Red Words with a descriptive single word. ie Mrs Jones becomes GREETING
repeats are fine so John Smith becomes AGENT wherever it occurs.
Finally run the macro and save the dotx.
I have the Access code to set the DOCVARIABLES to data from the database already written.
So when the typist wants to write a letter from Access she just presses a button and ……….bingo.
The typist doesnt have to know anything about bookmarks or docvariables and all that odd stuff.
Trouble is its so weird I cant get it to work as I want!
The Docvariable name is taken from the red word it replaces.
I am sorry I dont know if you can post code here or not but here it is anyway
ActiveDocument.Content.Select
With Selection.Find
.Font.Color = wdColorRed
End With
Do While Selection.Find
If Selection.Find.Execute Then
Selection.Select
myVar = Selection.Text
Debug.Print myVar
Selection.Fields.Add Range:=Selection.Range, _
Type:=wdFieldEmpty, _
Text:=”DOCVARIABLE ” & myVar, _
PreserveFormatting:=True
End If
Loop
This does not work for me, I use WORD 2010. I get stuck in the loop putting in infinite docvariable lines.
help please