I am creating a console that finds blocks with a certain attribute value and replace it with another (akin to find(textbox1) and replace(textbox2) in Word).
For Each blk In ss
If (blk.HasAttributes) Then
attr = blk.GetAttributes()
For i = 0 To UBound(attr)
If attr(i).TagString = "item" And _
attr(i).TextString = TextBox1.Value Then
attr(i).TextString = TextBox2.Value
Exit For
End If
Next
End If
Next
Although I have solved it, a new problem arose. My colleagues now want to filter by 2 attributes. For example, the attribute with the tag "item" can have the value "coke". But you might want to change only the name of the blocks that contain the soda and not the drug. As such, I picked another attribute which differentiates them (textbox11).
For Each blk In ss
If (blk.HasAttributes) Then
attr = blk.GetAttributes()
For i = 0 To UBound(attr)
If attr(i).TagString = "origin" And attr(i).TextString = TextBox11.Value Then
attr = 0
attr = blk.GetAttributes()
For o = 0 To UBound(attr)
If attr(i).TagString = "item" And _
attr(i).TextString = TextBox1.Value Then
attr(i).TextString = TextBox2.Value
Exit For
End If
End If
Next
End If
Next
But it's not working. How would you approach the problem?