Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-15-2021, 05:59 PM
Rayroshi Rayroshi is offline Make a Macro Run In 'Search and Replace?' Windows 7 64bit Make a Macro Run In 'Search and Replace?' Office 2003
Novice
Make a Macro Run In 'Search and Replace?'
 
Join Date: May 2011
Posts: 21
Rayroshi is on a distinguished road
Default Make a Macro Run In 'Search and Replace?'

Is it possible, using Word 2007, to place a macro into the 'Search/Replace' tool, so that it will find all possible ocurrences of the specified 'search' item, then replace them with the specified 'replace' item?

I have a long list of items in a receipt that contains a lot of spaces. The spaces make the receipt over 20 pages in length. By removing the spaces, it would shorten the receipt to only one page, which would make it nicer to print, of course.



So, for example, I would like to remove the spaces from this:

1. Great Value Honey Roasted Peanuts, 16 oz
Qty1
$1.98
($1.98/ea),

making it look like this:

1. Great Value Honey Roasted Peanuts, 16 oz Qty1 $1.98 ($1.98/ea)


Not sure how to do that, so any help would be greatly appreciated. (The actual receipt has far more spaces than what I have shown)
Reply With Quote
  #2  
Old 01-15-2021, 06:53 PM
macropod's Avatar
macropod macropod is offline Make a Macro Run In 'Search and Replace?' Windows 10 Make a Macro Run In 'Search and Replace?' Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

It's not apparent that you need anything other than a wildcard Find/Replace for this but, without seeing a document containing some representative content, it's impossible to know for sure. You can attach a document to a post via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 01-15-2021, 09:10 PM
Rayroshi Rayroshi is offline Make a Macro Run In 'Search and Replace?' Windows 7 64bit Make a Macro Run In 'Search and Replace?' Office 2003
Novice
Make a Macro Run In 'Search and Replace?'
 
Join Date: May 2011
Posts: 21
Rayroshi is on a distinguished road
Default

Hi Macropod,

Thanks for your help. I've never used the wildcard function before, so maybe you could coach me on that? I'd really appreciate it.

Thanks again!
Attached Files
File Type: docx Sample.docx (35.6 KB, 9 views)
Reply With Quote
  #4  
Old 01-17-2021, 04:27 PM
Guessed's Avatar
Guessed Guessed is offline Make a Macro Run In 'Search and Replace?' Windows 10 Make a Macro Run In 'Search and Replace?' Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Most of this can be done by:
Find: ^13(Qty[0-9]{1,})^13
Replace With: " \1 " without the quotes but with spaces either side of the \1

You can add Format>Paragraph>Alignment=Left to the Replace With box to make sure the result aligns left.

A separate find replace can be used to bring the return($ onto the same line. For that one you can:
Find: ^13(\($)
Replace with: " \1"
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #5  
Old 01-17-2021, 05:48 PM
Rayroshi Rayroshi is offline Make a Macro Run In 'Search and Replace?' Windows 7 64bit Make a Macro Run In 'Search and Replace?' Office 2003
Novice
Make a Macro Run In 'Search and Replace?'
 
Join Date: May 2011
Posts: 21
Rayroshi is on a distinguished road
Default

Thanks 'Guessed,' I will give that a try. I've never used the wildcard stuff, before, so I don't know what each of them stand for.

I really appreciate your help.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to search names/ids and replace text in another column Kalü Excel Programming 1 12-06-2018 07:14 PM
Adding terms to a search & replace macro Ulodesk Word VBA 6 03-29-2018 05:30 AM
Macro on Search and Replace davidhuy Word VBA 1 12-19-2014 04:47 AM
Make a Macro Run In 'Search and Replace?' Macro to search warning text style and replace the text color rohanrohith Word VBA 3 11-27-2014 01:08 PM
Search and Replace - Clear Search box JostClan Word 1 05-04-2010 08:46 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:40 AM.


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