Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-28-2015, 07:11 PM
Guessed's Avatar
Guessed Guessed is offline Bolding in script Windows 7 32bit Bolding in script Office 2010 32bit
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,159
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

You don't need to bother with a search and replace if you make use of the selection.expand method. For instance, you could add the following in front of the End If line


Code:
  Dim oPar As Paragraph
  For Each oPar In oRng.Paragraphs
    oPar.Range.Select
    Selection.Collapse Direction:=wdCollapseStart
    Selection.Extend " "
    Selection.Font.Bold = True
  Next oPar
This would be much slicker if you could use the range directly and didn't need the selection object but I don't think extend works for ranges.
Reply With Quote
  #2  
Old 01-28-2015, 07:20 PM
macropod's Avatar
macropod macropod is offline Bolding in script Windows 7 64bit Bolding in script Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,366
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 Guessed View Post
This would be much slicker if you could use the range directly and didn't need the selection object but I don't think extend works for ranges.
how about:
Code:
Dim oPar As Paragraph
  For Each oPar In oRng.Paragraphs
    With oPar.Range
      .Collapse Direction:=wdCollapseStart
      .MoveEndUntil " ", wdForward
      .Font.Bold = True
    End With
  Next oPar
Much more efficient than working with selections, too.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with VBA script nsyrax Word VBA 1 01-18-2014 03:38 AM
Bolding in script Outlook Script Help TheInfinetGroup Outlook 1 03-02-2013 07:43 AM
Add Shared Calendar using script Antros Outlook 0 03-15-2012 01:01 PM
Bolding in script Script Doesn't works on other machine ravininave Word 1 01-05-2011 01:45 PM
[ask] about VB Script + Ms. Project anak_baru Project 2 03-10-2009 01:42 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:45 PM.


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