Rob
Rob

Reputation: 1

VBA find replace within a line break

I am currently trying to modify my find and replace macro in order for it to read a line break. For example: I am trying to replace the following. Here is part of my code.

Dim changedXml As String
changedXml = Replace(strXml, "</graphic></figure></foldout>", "reproductionWidth=*+1")

As you can see I'm trying to replace, graphic, figure, foldout, with reproductionWidth=*+1 The only issue is the macro doesn't replace it because on my XML files they have line breaks between each one so it's making my macro not read them so nothing gets changed.

This is how they look on my XML file

</graphic>
</figure>
</foldout>

Does anyone know a solution to my problem? Thank you for any help in advance.

Upvotes: 0

Views: 218

Answers (1)

Brian M Stafford
Brian M Stafford

Reputation: 8868

Since you know your XML has line breaks, you need to include those in your Replace statement:

changedXml = Replace(strXml, "</graphic>" & vbCrLf & "</figure>" & vbCrLf & "</foldout>", "reproductionWidth=*+1")

If the line breaks are something other than vbCrLf you may need to update the code.

Upvotes: 1

Related Questions