Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-09-2014, 01:39 PM
ysostarman ysostarman is offline macro to format selected text with curly quotes Windows XP macro to format selected text with curly quotes Office XP
Novice
macro to format selected text with curly quotes
 
Join Date: Nov 2014
Posts: 5
ysostarman is on a distinguished road
Default macro to format selected text with curly quotes

Hi,
I have a set of documents (word 97 - I can't afford the 'new' office versions) that will build into a novel. Since there is a lot of dialogue, I would like to replace the existing straight sets of double quotes with curly 'smart' double quotes. The 'replace as you type' formatting won't work, since the text has already been typed.
Surely there must be a macro to do the following:


1) User selects text (which includes the opening and closing quotes)
2) Running the macro replaces the 'straight' pairs of quotes with 'curly' quotes.
3) It would also be good to have the user select text and then run a macro to surround it with curly quotes! - but this is a separate thing, so no need to bust a gut about it...
Reply With Quote
  #2  
Old 11-09-2014, 08:17 PM
macropod's Avatar
macropod macropod is offline macro to format selected text with curly quotes Windows 7 64bit macro to format selected text with curly quotes Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,375
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

You don't need a macro for that - a simple Find Replace for " will apply smart quotes throughout the document (or on just a selected range).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 11-09-2014, 11:02 PM
gmayor's Avatar
gmayor gmayor is offline macro to format selected text with curly quotes Windows 7 64bit macro to format selected text with curly quotes Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,138
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 ofgmayor has much to be proud of
Default

You can certainly do this with the replace function as Paul says - i.e. straight quotes to smart quotes (don't forget to set the format as you type option to set smart quotes or the replacement won't achieve anything), but if you might want to change it back again you will need a macro. You will find some basic code at:

http://www.gmayor.com/word_vba_examples_4.htm
__________________
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
  #4  
Old 11-10-2014, 07:44 AM
ysostarman ysostarman is offline macro to format selected text with curly quotes Windows XP macro to format selected text with curly quotes Office XP
Novice
macro to format selected text with curly quotes
 
Join Date: Nov 2014
Posts: 5
ysostarman is on a distinguished road
Default tried and no success

No joy - tried this and the quotes remained as straight as ever! I don't want things replaced "as I type" - the text has already been typed, with straight quote marks. It's these that need to be replaced. But I will take a look at the link to the macros, ta.
Reply With Quote
  #5  
Old 11-10-2014, 08:02 AM
gmayor's Avatar
gmayor gmayor is offline macro to format selected text with curly quotes Windows 7 64bit macro to format selected text with curly quotes Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,138
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 ofgmayor has much to be proud of
Default

You DO want what the autoformat as you type option set while you run the search and replace. That's what causes the replacement to 'retype' the quotes for them to be converted to smart quotes. You can turn off the option afterwards.
__________________
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
  #6  
Old 11-10-2014, 09:42 AM
ysostarman ysostarman is offline macro to format selected text with curly quotes Windows XP macro to format selected text with curly quotes Office XP
Novice
macro to format selected text with curly quotes
 
Join Date: Nov 2014
Posts: 5
ysostarman is on a distinguished road
Default still no joy

Hi Graham,
Nope... put some straight quotes around a bit of text, made sure that the 'autoformat as you type' option for smart quotes was on, did the find and replace, and still have straight quotes!
Actually, I think I may have tried this in the past with the same result, which is why I was trying to come up with a macro.
Reply With Quote
  #7  
Old 11-10-2014, 02:07 PM
macropod's Avatar
macropod macropod is offline macro to format selected text with curly quotes Windows 7 64bit macro to format selected text with curly quotes Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,375
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

Go to File|Options|Proofing>AutoCorrect Options>AutoFormat As You Type and make sure the "Straight Quotes" with “Smart Quotes” option is checked. Also, if you're doing the Find/Replace manually, your Replacement expression needs to be ", not ^&. A macro to do the replacement would work most efficiently by using the same process.

If it still doesn't work, perhaps the issue is related to your Windows Regional Settings. If they're configured for other than an English-language region, the " may not be recognised as a quote character for your region.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 11-10-2014, 02:51 PM
ysostarman ysostarman is offline macro to format selected text with curly quotes Windows XP macro to format selected text with curly quotes Office XP
Novice
macro to format selected text with curly quotes
 
Join Date: Nov 2014
Posts: 5
ysostarman is on a distinguished road
Default

Nobody has mentioned ^& so I'm not sure what that is! I just felt sure there had to be a way to write a macro which would find in a piece of selected text first of all the ascii for 'opening straight quote', replace it with an 'opening curly quote' then do the same for the parallel closing quotes. As the saying goes, it shouldn't be rocket science (and I do rocket science! - well, astronomy anyway) hence the name.
While on the subject of names, I love yours... macropods = kangaroos, yes?
Reply With Quote
  #9  
Old 11-10-2014, 04:22 PM
macropod's Avatar
macropod macropod is offline macro to format selected text with curly quotes Windows 7 64bit macro to format selected text with curly quotes Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,375
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

As I said, a macro would do basically the same as what you've been advised to do manually:
Code:
Sub Demo()
Dim bSmtQt As Boolean
bSmtQt = Options.AutoFormatAsYouTypeReplaceQuotes
Options.AutoFormatAsYouTypeReplaceQuotes = True
With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Text = """"
  .Replacement.Text = """"
  .Forward = True
  .Wrap = wdFindStop
  .Format = False
  .MatchCase = False
  .MatchWholeWord = False
  .MatchWildcards = False
  .MatchSoundsLike = False
  .MatchAllWordForms = False
  .Execute Replace:=wdReplaceAll
End With
Options.AutoFormatAsYouTypeReplaceQuotes = bSmtQt
End Sub
And yes, macropods = kangaroos.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #10  
Old 11-11-2014, 10:11 AM
ysostarman ysostarman is offline macro to format selected text with curly quotes Windows XP macro to format selected text with curly quotes Office XP
Novice
macro to format selected text with curly quotes
 
Join Date: Nov 2014
Posts: 5
ysostarman is on a distinguished road
Default partial success

Okay, partial success...
if I turn off smart quotes and type some text so that we get straight quotes, then run the macro, we do indeed end up with curlies.
However, if there is existing text, running the macro leaves us with straight quotes, irrespective of whether the option is turned off or on (I tried it with both, and the result was the same; no curly quotes). Ho hum...
Reply With Quote
  #11  
Old 11-11-2014, 12:51 PM
macropod's Avatar
macropod macropod is offline macro to format selected text with curly quotes Windows 7 64bit macro to format selected text with curly quotes Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,375
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

Can you attach a document to a post with some of the quote characters that don't convert (delete anything sensitive)? You do this 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
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to find text in between two characters and then format selected text? qcom Word 5 02-19-2015 11:23 PM
Replace curly ("66") quotes JeremyH Word 4 11-07-2013 05:43 AM
curly quotes after em-dash or hard space btorrance Word 0 06-07-2013 07:39 AM
Balky Curly Quotes JamesT Word 0 01-23-2010 05:36 PM
format cells to automatically place quotes around text dirtleg Excel 1 09-16-2008 01:52 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:14 AM.


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