Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Word VBA

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 01-09-2017, 06:20 AM
lonesoac0 lonesoac0 is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Oct 2015
Posts: 9
lonesoac0 is on a distinguished road
Default Convert Border Line to Under line chars

Hello all,



I have about 5k word files that have inconsistent lining. Some files have Border Lines, some have underscore lines and some have a combination of both. I would like to convert all Border Lines into the Underline Characters. I tried to record a macro to undo the AutoMatic formatting that changed the underscores to Border Lines but the little lightning thing went away every time I hit the record button.

Please advise
Reply With Quote
  #2  
Old 01-09-2017, 02:42 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 16,561
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

So we don't spend time trying to change the wrong kind of borders, can you attach a document to a post with some representative content (delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 01-09-2017, 02:56 PM
lonesoac0 lonesoac0 is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Oct 2015
Posts: 9
lonesoac0 is on a distinguished road
Default

Thank you! File attached.
Attached Files
File Type: docx 123.docx (15.5 KB, 1 views)
Reply With Quote
  #4  
Old 01-09-2017, 04:48 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 16,561
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Try the following macro:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim i As Long
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "[^13]{2,}"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
    For i = 1 To .Paragraphs.Count
      With .Paragraphs(i)
        If .Borders(wdBorderBottom).LineStyle <> wdLineStyleNone Then
          .Borders(wdBorderBottom).LineStyle = wdLineStyleNone
          .Range.InsertBefore "______________________" & _
            "________________________________________" & _
            "_________________________________________"
        End If
      End With
    Next
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
End Sub
For PC macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm
For Mac macro installation & usage instructions, see: http://word.mvps.org/Mac/InstallMacro.html
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #5  
Old 01-09-2017, 05:26 PM
lonesoac0 lonesoac0 is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Oct 2015
Posts: 9
lonesoac0 is on a distinguished road
Default

You are da man! It works like a charm. Thank you.
Reply With Quote
Reply

Tags
formatting, macro

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drawing a border/line in a table Bluie Word 3 10-24-2016 05:31 AM
Use character instead of line for table border dlowrey Word Tables 6 03-09-2015 11:29 AM
How to draw double line border for a Cell phamh PowerPoint 2 10-21-2014 02:26 PM
[Q] Horizontal border-lines after each text-line subscriber Word 2 05-14-2014 07:17 AM
Need to remove a line that isn't a cell border msbytes Word 4 08-15-2011 09:21 AM


All times are GMT -7. The time now is 04:02 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft