Using current selection in a word macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm having an issue with word macros.

I'm trying to create a number of macros which involve doing certain things
to whatever is selected, for example:

Thanks some text, and put HTML tags round it so that "link text here" would
become "<a href="" title="">code example here</a>".

Anyone know if this is possible?
 
Hi Sebastian

VBA in Word always makes the Selection object available, and from that you
can work out what text, if any, the user has selected.

If you're new to VBA programming, you might like to see

Creating a macro with no programming experience using the recorder
http://www.word.mvps.org/FAQs/MacrosVBA/UsingRecorder.htm
and
How to modify a recorded macro
http://www.word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm

If you have follow up questions, you might like to use one of the VBA
newsgroups such as microsoft.public.word.vba.general.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
Back
Top