![]() |
|
#1
|
|||
|
|||
|
Hello, I need help with making a macro for repeatedly adding specific styles to parts of the table, to loop trough the document until the text "%string" is found.
So I would need to apply a style, move a few 'tabs', add a new style, move 'tabs', until "%string" is found: Code:
Selection.Style = ActiveDocument.Styles("style1")
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.Style = ActiveDocument.Styles("style1")
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Thank you. Ivan. |
|
#2
|
|||
|
|||
|
Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim lngIndex As Long
Do
Selection.Style = ActiveDocument.Styles("style 1")
For lngIndex = 1 To 6
Selection.MoveRight Unit:=wdCell
If Left(Selection.Cells(1).Range.Text, Len(Selection.Cells(1).Range.Text) - 2) = "%string" Then Exit Do
Next lngIndex
Loop
lbl_Exit:
Exit Sub
End Sub
|
|
#3
|
|||
|
|||
|
works like a charm, thank you!
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| VBA Word Table - Select More than 1 Column at a time - Apply Formatting | jc491 | Word VBA | 12 | 09-24-2015 06:03 AM |
Word 2013: My custom table styles disappeared from Gallery
|
sinz54 | Word Tables | 1 | 03-13-2015 05:02 PM |
how to apply table style WITHOUT setting it as a table?
|
dylansmith | Excel | 9 | 05-16-2014 07:25 PM |
How 2 Save Table Properties & Apply to other table
|
Popeye.Tom | Word Tables | 1 | 04-24-2013 09:44 PM |
| Paragraph space before - can styles apply it intelligently? | timpani | Word | 7 | 10-23-2012 04:08 PM |