Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 02-25-2016, 09:09 AM
gmaxey gmaxey is offline Problem with highlighting text within a Macro Windows 7 32bit Problem with highlighting text within a 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

I don't' have time to code this for you, but the first thing I would do is abandon the selection approach:

Code:
Sub Z_BCR3ContentNewX()
Dim Reference As String
Dim strTopLine As String
Dim HOR As String
Dim ToAll As String
Dim oRng As Word.Range
Dim oFld As Field
  Set oRng = Selection.Range
  With oRng
    With .Font
      .Size = 10
      .Name = "Arial"
    End With
    strTopLine = InputBox("Top Line?, If blank remember to remove line", "")
    If strTopLine <> vbNullString Then
      .Text = strTopLine & vbCr
      .Paragraphs.Last.SpaceAfter = 12
    End If
    .Collapse wdCollapseEnd
    Set oFld = Fields.Add(oRng, wdFieldEmpty, "MERGEFIELD LQCASE_NAME", True)
    .End = oFld.Result.End
    .Collapse wdCollapseEnd
    .Text = vbCr
    .Collapse wdCollapseEnd
    Set oFld = Fields.Add(oRng, wdFieldEmpty, "MERGEFIELD ADD", True)
    .End = oFld.Result.End
    .Collapse wdCollapseEnd
    .Text = vbCr
    .Paragraphs.Last.SpaceAfter = 12
    .Collapse wdCollapseEnd
    HOR = InputBox("Highlighted OR?", "")
    If HOR <> vbNullString Then
      .Text = HOR & vbCr
      .HighlightColorIndex = wdTurquoise
      .Paragraphs.Last.SpaceAfter = 36
    End If
    .Collapse wdCollapseEnd
    .Text = "Our Ref:"
    .Bold = True
    .Collapse wdCollapseEnd
    'and so on
  End With
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with highlighting text within a Macro Unwanted text highlighting AllusiveKitten Word 2 07-20-2015 04:00 PM
Highlighting Text After Sync lvautier OneNote 1 02-07-2015 04:02 PM
Problem with highlighting text within a Macro How to solve highlighting problem in Template magpie Word 7 01-24-2012 06:21 AM
Problem with highlighting text within a Macro Macro for highlighting specific number of words icsjohn Word VBA 2 12-07-2011 06:44 PM
HELP: Automatically highlighting problem unhappyuser PowerPoint 0 05-03-2011 02:52 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:11 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