macros for formatting in Word

  elgar 13:15 28 Oct 04
Locked

I want to write a macro in MS Word to automatically insert quote marks around selected text, e.g. convert I know you are there to "I know you are there" with one click. Does anyone know how to do this?

  pj123 17:49 28 Oct 04

Don't need to use a macro. Set it up as Autotext and all you need do is type a short name and hit F3 and there it is.

  Peter 17:55 28 Oct 04

.

What about Find & Replace, i.e. Find I know you are there and Replace with "I know you are there". No need for a macro.

Peter.

  Alan2 22:01 28 Oct 04

Unless elgar comes back to say otherwise, I think he wants to be able to select "any text" then hit a key to put the double quotes around.


So a macro would be an efficient way to go about it.

  elgar 09:34 19 Feb 05

Yeah, thanks

I forgot about this post but still searching for an answer. What I need is exactly that, I want to be able to automatically put the speech marks around any sentence I select.

  VoG II 09:53 19 Feb 05

Sub qt()

Selection.InsertAfter Text:=""""

Selection.InsertBefore Text:=""""

End Sub

  Simsy 10:01 19 Feb 05

add the following as a module;


Sub AddQuoteMarks()

Dim quotation As String

quotation = Selection.Text

Selection.TypeText (""" & quotation & """)

End Sub


I've done this at work using Word XP.

You have to select the text first, then run the Macro. There will probably be issues if more than 1 block of text is selected.


I hope this helps,

Regards,

Simsy

  Simsy 10:31 19 Feb 05

not only has VoG™ beaten me to it, he also has provided a more elegant solution!

Regards,

Simsy

  Simsy 10:43 19 Feb 05

that in fact mine doesn't seem to work anyway!!!

Apologies,

Regards,

Simsy

  Simsy 11:22 19 Feb 05

mine does work when slightly ammended. the last line should be;


Selection.TypeText Text:="""" & quotation & """"


I got the clue from the formatting in VoG™'s posting.

Regards,

Simsy

  elgar 12:50 19 Feb 05

Thank you, another minor irritant solved.

This thread is now locked and can not be replied to.

How to get Windows 10 for free | How to install Windows 10: There is still a way to avoid paying…

1995-2015: How technology has changed the world in 20 years

Alex Chinneck’s giant ice cube Christmas tree at Kings Cross

Apple rumours & predictions 2017: The iPhone 8, new iPads, and everything else you should expect fr7…