Link to home
Start Free TrialLog in
Avatar of y2jk
y2jk

asked on

Simple Macro Required

I have a WORD document which is a 5 page long table of contents. I want to paste the contents into an html page. I DON'T want to do a "Save As Html" because that puts tons of formatting on the page, and makes it look like the original WORD document (I just want to paste the contents into an html page in keeping with the web site style).

I have done similar things with Excel, but trying to paste the WORD contents into Excel doesn't work either, due to the number of Carriage Returns in some of the cells.

What I want to be able to do is look for all carriage returns in the WORD document and replace them with some text , i.e. "<br>". I tried recording a macro so start me off, but I don't really understand what it's doing. The line that I think is doing what I need is:

    Selection.Delete Unit:=wdCharacter, Count:=1

I need to start from the top of the document, scroll all the way through it, and replace every instance of wdCharacter (I think!) with <br>.

I'm sure it's simple if you know how, although I'm offering points for a moderately difficult question (I like to be generous!). Can anyone help?
ASKER CERTIFIED SOLUTION
Avatar of mvidas
mvidas
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of y2jk
y2jk

ASKER

Perfect! I tried your first suggestion and it did exactly what I wanted. I may have a play with your longer suggestion another time, but for now it's done exactly what I needed. Thanks also for such a quick response.
Not a problem, the longer one just creates the html file for you.  Glad to help, and let me know if you need anything else!