Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-12-2015, 01:17 AM
1van 1van is offline Apply styles in word table Windows 7 64bit Apply styles in word table Office 2007
Novice
Apply styles in word table
 
Join Date: Nov 2015
Posts: 4
1van is on a distinguished road
Default Apply styles in word table

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
this is the number of 'tabs' that is required to position over the right part of the table.

Thank you. Ivan.
Reply With Quote
  #2  
Old 11-12-2015, 04:28 AM
gmaxey gmaxey is offline Apply styles in word table Windows 7 32bit Apply styles in word table Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,421
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 11-17-2015, 11:05 AM
1van 1van is offline Apply styles in word table Windows 7 64bit Apply styles in word table Office 2007
Novice
Apply styles in word table
 
Join Date: Nov 2015
Posts: 4
1van is on a distinguished road
Default

works like a charm, thank you!
Reply With Quote
Reply

Thread Tools
Display Modes


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
Apply styles in word table Word 2013: My custom table styles disappeared from Gallery sinz54 Word Tables 1 03-13-2015 05:02 PM
Apply styles in word table how to apply table style WITHOUT setting it as a table? dylansmith Excel 9 05-16-2014 07:25 PM
Apply styles in word table 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

Other Forums: Access Forums

All times are GMT -7. The time now is 03:43 AM.


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