Solved

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

Posted on 2010-08-18
4
664 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
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
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 walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

776 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