Solved

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

Posted on 2010-08-18
4
680 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 6

Expert Comment

by:PhilAI
ID: 33467067
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
ID: 33467505
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
ID: 33468171
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
ID: 33470217
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
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…

733 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