Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-25-2016, 05:54 PM
gmaxey gmaxey is offline Reverse Bold macro Windows 7 32bit Reverse Bold macro Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,636
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

You have already had one suggesting which apparently you ignored. Paul's code seems fast to me. The only possible issue with it is that it pukes if your selection happens to include the final paragraph mark.

You can try:

Code:
Sub ReverseBoldII()
Dim oRng As Range
Application.ScreenUpdating = False
Set oRng = Selection.Characters.First
  Do
    oRng.Font.Bold = Not oRng.Font.Bold
    Set oRng = oRng.Characters.Last.Next
  Loop Until oRng.Start = Selection.Characters.Last.Start
  Application.ScreenUpdating = True
End Sub

__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #2  
Old 02-25-2016, 06:28 PM
macropod's Avatar
macropod macropod is offline Reverse Bold macro Windows 7 64bit Reverse Bold macro Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,526
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by gmaxey View Post
Paul's code seems fast to me. The only possible issue with it is that it pukes if your selection happens to include the final paragraph mark.
Thanks for the heads-up. That could be remedied by replacing:
Set Rng = Selection.Characters.First
with:
Code:
With Selection
  Set Rng = .Characters.First
  If .End = ActiveDocument.Range.End Then
    .Characters.Last.Font.Bold = Not .Characters.Last.Font.Bold
    .End = .End - 1
  End If
End With
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 02-25-2016, 07:10 PM
brent chadwick brent chadwick is offline Reverse Bold macro Windows 8 Reverse Bold macro Office 2013
Advanced Beginner
Reverse Bold macro
 
Join Date: Mar 2015
Posts: 86
brent chadwick is on a distinguished road
Default

Thanks Paul for the change in the code, works well. Greg, yours worked well also but it really messed up my bookmarks. Thanks to all for the help-
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Reverse Bold macro Macro to find and replace headings in bold and underline redzan Word VBA 4 02-13-2016 12:24 PM
Creating macro in 2007 to bold within quotes on the fly marymaryt Word VBA 5 06-01-2015 06:55 AM
Macro Needed to bold specific lines and Macro to turn into CSV anewteacher Word VBA 1 05-28-2014 03:59 PM
Macro to reverse a test string Jennifer Murphy Word VBA 5 01-16-2014 03:19 PM
Format Bold in one line makes all lines bold Nitte Word 2 02-07-2013 12:34 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:28 AM.


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