Home Forums General XMetaL Discussion Makro Search Entity and Replace it Reply To: Makro Search Entity and Replace it

ndudek

Reply to: Makro Search Entity and Replace it

Hi Derek,

thanks for your input. I'm close to the final solution but it doesn't work.

It seems like there is something wrong with the “IsLessThan” Method. I'm working in VBScript but that shouldn't be the problem.
Following Document:
[code]




]>

  t est

[/code]

Following Macro:
[code]
ActiveDocument.Host.DisplayAlerts = 0
Dim entRefToReplace
entRefToReplace = “nbsp”
Dim textToInsert
textToInsert = ” “
Dim rng1
Set rng1 = ActiveDocument.Range
rng1.HomeKey
Dim rng2
Set rng2 = rng1.Duplicate
rng1.GotoNext(0)
while rng2.IsLessThan(rng1)
if rng2.ContainerName = “.ENTREF” Then
if rng2.ContainerNode.nodeName = entRefToReplace Then
rng2.SelectElement
rng2.Delete
rng2.Text = textToInsert
End if
End if
rng2.GotoNext(0)
rng1.GotoNext(0)
wend
ActiveDocument.Host.DisplayAlerts = -1
[/code]

It just replace nothing here. Maybe because there is no Element after the nbsp?

Reply

Products
Downloads
Support