Hello world
I'm having some problems creating a macro in VBA for Word (2010).
So far I made it (with the search function of these forums) to loop through all sections and find fields and to delete them and insead insert own TEXT pattern.
At the moment my code looks like this:
[VBA]
Option Explicit
Public Sub FieldsToWildcards()
Dim aField As field
Dim pRange As Word.Range
Dim pattern As String
For Each pRange In ActiveDocument.StoryRanges
For Each aField In pRange.Fields
Set pRange = aField.Code
aField.Delete
pRange.Collapse (wdCollapseStart)
pRange.Text = "${A[;B]}"
Next
Next
End Sub
[/VBA]
I now need some line of code, which will transform this:
{ IF «sex» = "f" "She" "He" }, (which is btw. a field) INTO this ${She;He} (text)
AND this:
{ MERGEFIELD Name } (field) INTO this ${Name} (text)
I would appreciate any help.
Thank you,
Kind regards