View Single Post
 
Old 05-04-2016, 02:55 PM
djpemberton djpemberton is offline Windows 7 32bit Office 2010 32bit
Novice
 
Join Date: Mar 2014
Posts: 2
djpemberton is on a distinguished road
Default Find and Replace Macro Need

I am formating a new Bible translation for a certain software.

The original document looks like this:

Code:
[[@Bible:mat 1:1]][[1>>Bible:mat 1:1]] ईसा मसीह बिन दाऊद बिन इब्राहीम का नसबनामा : 

[[@Bible:mat 1:2]][[2>>Bible:mat 1:2]] इब्राहीम इस्हाक़ का बाप था, इस्हाक़ याक़ूब का बाप और याक़ूब यहूदा और उस के भाइयों का बाप। 
[[@Bible:mat 1:3]][[3>>Bible:mat 1:3]] यहूदा के दो बेटे फ़ारस और ज़ारह थे (उन की माँ तमर थी)। फ़ारस हस्रोन का बाप और हस्रोन राम का बाप था। 
[[@Bible:mat 1:4]][[4>>Bible:mat 1:4]] राम अम्मीनदाब का बाप, अम्मीनदाब नह्सोन का बाप और नह्सोन सल्मोन का बाप था। 
[[@Bible:mat 1:5]][[5>>Bible:mat 1:5]] सल्मोन बोअज़ का बाप था (बोअज़ की माँ राहब थी)। बोअज़ ओबेद का बाप था (ओबेद की माँ रूत थी)। ओबेद यस्सी का बाप और 
[[@Bible:mat 1:6]][[6>>Bible:mat 1:6]] यस्सी दाऊद बादशाह का बाप था।
I need to add {{field-off:Bible}} and {{field-on:Bible}} markers at specific places around each verse, resulting in this:

Code:
[[@Bible:Matt 1:1]][[1>>Bible:Matt 1:1]]{{field-on:Bible}} ईसा मसीह बिन दाऊद बिन इब्राहीम का नसबनामा :{{field-off:Bible}}
 
[[@Bible:Matt 1:2]][[2>>Bible:Matt 1:2]]{{field-on:Bible}} इब्राहीम इस्हाक़ का बाप था, इस्हाक़ याक़ूब का बाप और याक़ूब यहूदा और उस के भाइयों का बाप।{{field-off:Bible}}
[[@Bible:Matt 1:3]][[3>>Bible:Matt 1:3]]{{field-on:Bible}} यहूदा के दो बेटे फ़ारस और ज़ारह थे (उन की माँ तमर थी)। फ़ारस हस्रोन का बाप और हस्रोन राम का बाप था।{{field-off:Bible}}
[[@Bible:Matt 1:4]][[4>>Bible:Matt 1:4]]{{field-on:Bible}} राम अम्मीनदाब का बाप, अम्मीनदाब नह्सोन का बाप और नह्सोन सल्मोन का बाप था।{{field-off:Bible}}
[[@Bible:Matt 1:5]][[5>>Bible:Matt 1:5]]{{field-on:Bible}} सल्मोन बोअज़ का बाप था (बोअज़ की माँ राहब थी)। बोअज़ ओबेद का बाप था (ओबेद की माँ रूत थी)। ओबेद यस्सी का बाप और{{field-off:Bible}}
[[@Bible:Matt 1:6]][[6>>Bible:Matt 1:6]]{{field-on:Bible}} यस्सी दाऊद बादशाह का बाप था।
  
दाऊद सुलैमान का बाप था (सुलैमान की माँ पहले ऊरिय्याह की बीवी थी){{field-off:Bible}}
Here is a Macro that I had created for it a while back:

Code:
Sub LogosField()
'
' LogosField Macro
'
'
With ActiveDocument.Content.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Text = "\[\[*\]\]\[\[*\]\]"
  .Replacement.Text = "{{field-off:Bible}}^&{{field-on:Bible}}"
  .Forward = True
  .Wrap = wdFindContinue
  .Format = False
  .MatchWildcards = True
  .Execute Replace:=wdReplaceAll
End With
End Sub
It gets close, but results in this:

Code:
{{field-off:Bible}}[[@Bible:mat 1:1]][[1>>Bible:mat 1:1]]{{field-on:Bible}} ईसा मसीह बिन दाऊद बिन इब्राहीम का नसबनामा :

{{field-off:Bible}}[[@Bible:mat 1:2]][[2>>Bible:mat 1:2]]{{field-on:Bible}} इब्राहीम इस्हाक़ का बाप था, इस्हाक़ याक़ूब का बाप और याक़ूब यहूदा और उस के भाइयों का बाप।
{{field-off:Bible}}[[@Bible:mat 1:3]][[3>>Bible:mat 1:3]]{{field-on:Bible}} यहूदा के दो बेटे फ़ारस और ज़ारह थे (उन की माँ तमर थी)। फ़ारस हस्रोन का बाप और हस्रोन राम का बाप था।
{{field-off:Bible}}[[@Bible:mat 1:4]][[4>>Bible:mat 1:4]]{{field-on:Bible}} राम अम्मीनदाब का बाप, अम्मीनदाब नह्सोन का बाप और नह्सोन सल्मोन का बाप था।
{{field-off:Bible}}[[@Bible:mat 1:5]][[5>>Bible:mat 1:5]]{{field-on:Bible}} सल्मोन बोअज़ का बाप था (बोअज़ की माँ राहब थी)। बोअज़ ओबेद का बाप था (ओबेद की माँ रूत थी)। ओबेद यस्सी का बाप और
{{field-off:Bible}}[[@Bible:mat 1:6]][[6>>Bible:mat 1:6]]{{field-on:Bible}} यस्सी दाऊद बादशाह का बाप था।

दाऊद सुलैमान का बाप था (सुलैमान की माँ पहले ऊरिय्याह की बीवी थी)।
{{field-off:Bible}}
As you can see, the "field-on" markers are correctly placed, but the "field-off" markers come just before the "[[@Bible . . ." instead of just after the last text before "[[@Bible . . ."

Any suggestions?
Reply With Quote