![]() |
|
#1
|
|||
|
|||
|
Hi there,
Sorry for the title being almost meaningless. I have a table, one cell contains a single line or multiple lines of reference (e.g TST/PRF/25/64) I need to do the following for EACH line: a) Content before the first slash must be bold, 14pt b) Content after the first slash is not bold, 11pt ...BUT if content at the second slash is "VST" or "PKE" then it should be bold, 14pt too. I really failed on that one, ranges and moving in ranges get me crazy ![]() Some help would be grateful Attached is the TEST-reference.dotm with the FixIt macro. |
|
#2
|
||||
|
||||
|
There is no code in your template, however
Code:
Sub Macro1()
Dim oTable As Table
Dim oCell As Cell
Dim oRow As Row
Dim oPara As Paragraph
Dim oRng As Range
Set oTable = Selection.Tables(1)
For Each oRow In oTable.Rows
Set oCell = oRow.Cells(2)
oCell.Range.Font.Size = 11
For Each oPara In oCell.Range.Paragraphs
Set oRng = oPara.Range
oRng.Collapse (1)
oRng.MoveEndUntil "/"
oRng.Font.Bold = True
oRng.Font.Size = 14
oRng.Collapse (0)
oRng.Start = oRng.Start + 1
oRng.MoveEndUntil "/"
If InStr(1, oRng.Text, "VST") > 0 Or _
InStr(1, oRng.Text, "PKG") > 0 Then
oRng.Start = oRng.Start - 1
oRng.Font.Bold = True
oRng.Font.Size = 14
End If
Next oPara
Next oRow
Set oTable = Nothing
Set oCell = Nothing
Set oRow = Nothing
Set oPara = Nothing
Set oRng = Nothing
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
#3
|
|||
|
|||
|
Hi Graham,
Thanks for your reply. My bad, after verification in the Visual Consol, I actually wrote the macro in my Normal.dotm. Sorry. Thanks for the code, it looks good to me. I will give it a try. I was splitting at a slash but MoveEndUntil is a better alternative indeed as it moves along the process. |
|
#4
|
|||
|
|||
|
I works like a charm. Thanks a lot for your help
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Count occurences of 2 words (that are near each other)
|
petitfleur | Word VBA | 6 | 02-12-2020 10:40 PM |
| Find a text and delete the line above | Dzib | Word VBA | 1 | 09-10-2019 12:27 PM |
Parsing 'FullName' column - help needed text to column
|
ScottA | Excel Programming | 3 | 05-06-2014 12:49 PM |
Bad view when using Find and Find & Replace - Word places found string on top line
|
paulkaye | Word | 4 | 12-06-2011 11:05 PM |
Need help on Macro 03- Find text - if text is blank then remove line
|
simpleonline1234 | Word VBA | 1 | 02-25-2011 02:28 AM |