adding HTML tags

N

Natali

Hello everyone,

I'd like to select a part of the text in my doc file, and
by clicking a button(?) or macro (?) - an html tag of my
choice will appear.

for example, this sentense before the click:
John need to go to school

and after the click:
<b>John need to go to school</b>

i need tags for the HTML codes: <b> <u> <a href> <font>
<font size> and <font color>

do i need to create a special buttons for every tag? how
do i create such a thing?

thank you very much for you time.

natali
 
N

Natali Gotlieb

Dear Shauna Kelly,

Thank you very much for your time and helpful advises.
I'll try to do it via macros.
I appreciate your help.

Regards,

Natali Gotlieb
-----Original Message-----
Hi Natali

Here's code that will add <b> before and </b> after the
selected text (except that, if you select an entire
paragraph, it will put
the </b> before the paragraph mark, which I found useful
when I was hard-coding HTML in Word):
Sub SelectionToHTMLBold()
'Shauna Kelly, 19 August 2003 for
'microsoft.public.word.formatting.longdocs

If Selection.Characters.Last = Chr(13) Then
Selection.MoveEnd Unit:=wdCharacter, Count:=-1
End If
Selection.InsertBefore "<b>"
Selection.InsertAfter "</b>"

End Sub

If you're not sure what to do with the macro, see
http://www.gmayor.dsl.pipex.com/installing_macro.htm and
http://www.mvps.org/word/FAQs/MacrosVBA/CreateAMacro.htm

You can use Tools > Customize to allocate a keyboard
shortcut to a macro, or put the macro on a button on a
toolbar.
You could make similar macros to insert other beginning and end HTML tags.

However, bear in mind that Word does a half-decent job of
saving HTML itself. If you simply have bold text in the
document, and you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top