Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-30-2021, 11:43 AM
Rolo18 Rolo18 is offline VBA find replace within a line break Windows 10 VBA find replace within a line break Office 2016
Novice
VBA find replace within a line break
 
Join Date: Mar 2020
Posts: 20
Rolo18 is on a distinguished road
Default VBA find replace within a line break

Hello everyone,


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.
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.

Last edited by Rolo18; 04-30-2021 at 05:31 PM.
Reply With Quote
  #2  
Old 04-30-2021, 08:50 PM
gmayor's Avatar
gmayor gmayor is offline VBA find replace within a line break Windows 10 VBA find replace within a line break Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Code:
changedXml = Replace(strXml, "</graphic>" & Chr(11) & "</figure>" & Chr(11) & "</foldout>", "reproductionWidth=*+1")
works to change the string, but whether it will change the text in your document rather depends on what you do with changedXml subsequently.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 04-30-2021, 10:53 PM
macropod's Avatar
macropod macropod is online now VBA find replace within a line break Windows 10 VBA find replace within a line break Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Cross-posted at: ms word - VBA find replace within a line break - Stack Overflow
For cross-posting etiquette, please read: Excelguru Help Site - A message to forum cross posters
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA find replace within a line break Find and Replace not capturing entire line Steve Kunkel Word VBA 7 04-22-2021 10:00 AM
VBA find replace within a line break Find and Replace Line Spacing farisca Word 2 06-18-2020 04:02 PM
VBA find replace within a line break Find / Replace hard Carriage Return with Line break. GreenBoy Word 2 03-11-2018 02:32 AM
Interchange line break and paragraph break shortcut keys skan Word 2 01-20-2017 03:50 AM
VBA find replace within a line break Bad view when using Find and Find & Replace - Word places found string on top line paulkaye Word 4 12-06-2011 11:05 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:09 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft