#1
|
|||
|
|||
Search for character border = true ?
how can I search a document for everywhere that a character boarder = true and insert 'ChrW (9660)' before?
|
#2
|
|||
|
|||
I could be wrong, but I don't think .border returns true or false. Maybe something like this:
Code:
Sub ScratchMacro() 'A basic Word macro coded by Greg Maxey Dim oChr As Range For Each oChr In ActiveDocument.Range.Characters If oChr.Borders.OutsideLineWidth <> 0 Then oChr.InsertBefore ChrW(9660) End If Next End Sub |
#3
|
|||
|
|||
hi, thanks for your reply.
the code nearly works, but the character boarders contain whole words and not just 1 letter. so instead of putting 1 'ChrW(9660)' in front of every instance of a bordered word, it puts a 'ChrW(9660)' in front of every single letter making it look like ... >H>E>L>P instead of ... >HELP any ideas? Thanks |
#4
|
|||
|
|||
Try:
Code:
Sub ScratchMacro() 'A basic Word macro coded by Greg Maxey Dim oChr As Range Dim oRng As Word.Range For Each oChr In ActiveDocument.Range.Characters If oChr.Borders.OutsideLineWidth <> 0 Then If oChr.Previous.Borders.OutsideLineWidth = 0 Then oChr.InsertBefore ChrW(9660) End If End If Next End Sub |
#5
|
|||
|
|||
Awesome, you're amazing! it works perfectly thanks!
1 last thing, iv'e tried (but failed) to add on the code .size=8 .colour= 49407 .superscript = true (i keep screwing it up!) |
#6
|
|||
|
|||
You also need a bit of error handling in case the first character in the document is bordered:
Code:
Sub ScratchMacro() 'A basic Word macro coded by Greg Maxey Dim oChr As Range Dim oRng As Word.Range For Each oChr In ActiveDocument.Range.Characters If oChr.Borders.OutsideLineWidth <> 0 Then On Error GoTo Err_Range If oChr.Previous.Borders.OutsideLineWidth = 0 Then oChr.InsertBefore ChrW(9660) Set oRng = oChr.Characters(1) With oRng.Font .Size = 8 .Color = 49407 .Superscript = True End With End If End If ReEntry: Next lbl_Exit: Exit Sub Err_Range: ActiveDocument.Range.InsertBefore ChrW(9660) With ActiveDocument.Characters(1) .Borders(1).LineStyle = wdLineStyleNone With .Font .Size = 8 .Color = 49407 .Superscript = True End With End With Resume ReEntry End Sub |
#7
|
|||
|
|||
Thanks it works perfectly.
1 more question (if you have the time).... How can i search for all ChrW (9700) where character border = true, and apply .outline = true ? Thank you. |
Tags |
boarder, character border, insert |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
True Title Case for First Row of All Tables | Marrick13 | Word VBA | 14 | 12-11-2013 09:12 PM |
Aligning Page Border with Table border without losing formatting :mad: | l39linden | Word Tables | 5 | 10-04-2013 02:06 AM |
Character based Search and Replace font size | anacond11 | Word | 2 | 08-08-2013 08:10 AM |
How to change the color of Character Border? | tinfanide | Word | 4 | 10-27-2012 06:35 AM |
Macro not staying true | oluc | Word VBA | 4 | 11-21-2010 08:10 AM |