Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VBA code to bold all text occuring between two strings in a Word Table

Posted on 2009-05-04
3
Medium Priority
?
383 Views
Last Modified: 2013-11-25
Hi,
We need some VBA code to loop through cells in a Word Table and bold all text that falls between the following two strings respectively: "||" and ">>" (without removing the delimiters.)
For a quick preview see:
http://www.eligreen.com/share/Bold_String_Pattern.pdf
The code should work on the attached file. Please see.
Thank you
eg
Bold-String-Pattern.doc
0
Comment
Question by:PioneerSolutions
[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
3 Comments
 
LVL 21

Accepted Solution

by:
Eric Fletcher earned 2000 total points
ID: 24297488
The wildcard pattern I suggested for your earlier question can easily be modified to keep the delimiters. When I posted it, I assumed (incorrectly) that you wanted the delimiters removed as well. This does what you want on the file you posted.
Sub SetBold()
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Font.Bold = True
        .Text = "(|| )(*)( \>\>)"
        .Replacement.Text = "\1\2\3"
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll, Format:=True, Forward:=True
    End With
End Sub

Open in new window

0
 
LVL 21

Expert Comment

by:Eric Fletcher
ID: 24297496
The wildcard pattern I suggested for your earlier question can easily be modified to keep the delimiters. When I posted it, I assumed (incorrectly) that you wanted the delimiters removed as well. This does what you want on the file you posted.
Sub SetBold()
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Replacement.Font.Bold = True
        .Text = "(|| )(*)( \>\>)"
        .Replacement.Text = "\1\2\3"
        .MatchWildcards = True
        .Execute Replace:=wdReplaceAll, Format:=True, Forward:=True
    End With
End Sub

Open in new window

0
 

Author Closing Comment

by:PioneerSolutions
ID: 31577644
Thank you. eg.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.

721 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