Solved

How to get Word macro to replace html bullet codes with bullets in Word?

Posted on 2010-08-18
4
649 Views
Last Modified: 2012-06-22
Here is some text in my Word document. I need a macro to replace the html codes with Word bullets. This is part of a much longer document from a merge, so opening and converting is not an option. Thank you.
This is the start of this item. For example: <ul><li>The state may do this and that and blah blah blah text goes on and on for a few lines here asdlfkj asdl;kfj asdlfkj asd;lfk jasd;lfk jasdl;fk jasdfkl jasdfkl ajsdflk ajsdflk ajsdl;fk ajsd;fl ajsdfl;k ajsdl;fk ajsdlf ajsdfl; jsalf sdfj until the next bullet.</li><li>The schools will do this and that and that and this and on and on and on and on until the very next bullet point. </li><li>The next thing that happens is this and that and that and this and on and on asdlfj asldfj asldfjasl;dfj asl;dfkj as;ldfj asl;dfj asldf until the next point. </li><li>The next sentence is similar to the others about and goes on and on and on and on and this and that and that and this and so on and so forth and so on and so forth until the next bullet point.</li><li>This bullet point is comprised of three sentences that are all pretty long sentences, and this is sentence one. This bullet point is comprised of three sentences that are all pretty long sentences, and this is sentence two. This bullet point is comprised of three sentences that are all pretty long sentences, and this is sentence three. </li><li>Here is another one. </li><li>Just one more sentence here and on and on and on.</li></ul>
0
Comment
Question by:jswilkinsz
  • 2
  • 2
4 Comments
 
LVL 6

Expert Comment

by:PhilAI
Comment Utility
Can you provide a small sample HTML file rather than just a section? I'm not sure I understand exactly what you want. Are you trying to convert an HTML file to a Word document?
0
 

Author Comment

by:jswilkinsz
Comment Utility
The information comes from a spreadsheet, which is exported from a salesforce report. I have a merge in Word and then have some macros that deal with most of the codes, like <br> <p> etc.  The one problem I have is with the <li> codes and if there was a way to include something that searches for <li>, puts in the Word bullet, that is what I need. I could not find anything in replace under the special or formatting for bullet.
0
 

Accepted Solution

by:
jswilkinsz earned 0 total points
Comment Utility
I got this macro to work.

Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Style = ActiveDocument.Styles("List Bullet")
    With Selection.Find
        .Text = "<ul><li>"
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Style = ActiveDocument.Styles("List Bullet")
        Selection.Find.Execute Replace:=wdReplaceAll
    With Selection.Find
        .Text = "</li><li>"
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
0
 
LVL 6

Expert Comment

by:PhilAI
Comment Utility
Damn! I was just looking into that when I had to go out. Glad you figured it out for yourself - always feels better when you do that!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now