Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-08-2014, 03:24 AM
n00bie-n00b n00bie-n00b is offline Search for character border = true ? Windows 7 32bit Search for character border = true ? Office 2007
Novice
Search for character border = true ?
 
Join Date: Aug 2014
Posts: 17
n00bie-n00b is on a distinguished road
Talking Search for character border = true ?

how can I search a document for everywhere that a character boarder = true and insert 'ChrW (9660)' before?
Reply With Quote
  #2  
Old 10-08-2014, 06:15 AM
gmaxey gmaxey is offline Search for character border = true ? Windows 7 32bit Search for character border = true ? Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,428
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 10-08-2014, 05:29 PM
n00bie-n00b n00bie-n00b is offline Search for character border = true ? Windows 7 32bit Search for character border = true ? Office 2007
Novice
Search for character border = true ?
 
Join Date: Aug 2014
Posts: 17
n00bie-n00b is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 10-08-2014, 05:51 PM
gmaxey gmaxey is offline Search for character border = true ? Windows 7 32bit Search for character border = true ? Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,428
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #5  
Old 10-08-2014, 05:59 PM
n00bie-n00b n00bie-n00b is offline Search for character border = true ? Windows 7 32bit Search for character border = true ? Office 2007
Novice
Search for character border = true ?
 
Join Date: Aug 2014
Posts: 17
n00bie-n00b is on a distinguished road
Default

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!)
Reply With Quote
  #6  
Old 10-08-2014, 06:31 PM
gmaxey gmaxey is offline Search for character border = true ? Windows 7 32bit Search for character border = true ? Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,428
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #7  
Old 10-08-2014, 11:54 PM
n00bie-n00b n00bie-n00b is offline Search for character border = true ? Windows 7 32bit Search for character border = true ? Office 2007
Novice
Search for character border = true ?
 
Join Date: Aug 2014
Posts: 17
n00bie-n00b is on a distinguished road
Default

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.
Reply With Quote
Reply

Tags
boarder, character border, insert



Similar Threads
Thread Thread Starter Forum Replies Last Post
Search for character border = true ? True Title Case for First Row of All Tables Marrick13 Word VBA 14 12-11-2013 09:12 PM
Search for character border = true ? Aligning Page Border with Table border without losing formatting :mad: l39linden Word Tables 5 10-04-2013 02:06 AM
Search for character border = true ? Character based Search and Replace font size anacond11 Word 2 08-08-2013 08:10 AM
Search for character border = true ? How to change the color of Character Border? tinfanide Word 4 10-27-2012 06:35 AM
Search for character border = true ? Macro not staying true oluc Word VBA 4 11-21-2010 08:10 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:58 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft