?
Solved

run code on all of the tables omitting some of them

Posted on 2014-02-11
2
Medium Priority
?
269 Views
Last Modified: 2014-02-11
Dear Experts:

I would like to run below code (courtesy by Rgonzo1971, EE) not only on the selected table but on all of the tables in the active document with the exception of table 3, 5, 7 and 10.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas

Sub Format_Columns_Add_Decimal_tabs_selected_table()

Dim mytable As Table
Set d = ActiveDocument
Set mytable = Selection.Tables(1)
    With mytable
        For IdxRow = 2 To mytable.Rows.Count
            For IdxCol = 2 To 3
                Set c = mytable.Cell(IdxRow, IdxCol)
                c.Range.ParagraphFormat.TabStops.Add Position:=CentimetersToPoints(1.7) _
                    , Alignment:=wdAlignTabDecimal, Leader:=wdTabLeaderSpaces
                 Next
        Next
       .PreferredWidth = 97.5
       .PreferredWidthType = wdPreferredWidthPercent
       .Columns(2).Width = CentimetersToPoints(3.1)
       .Columns(3).Width = CentimetersToPoints(3.1)
       .PreferredWidth = 97.5
       .PreferredWidthType = wdPreferredWidthPercent
    End With
End Sub

Open in new window

0
Comment
Question by:AndreasHermle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 39849584
Hi,

pls try

Sub Format_Columns_Add_Decimal_tabs_selected_table()

'to be expanded by inserting a decimal tab at 1.7 cm in all cells starting from row 2 of Column 2 and 3


Dim mytable As Table
For IdxTable = 1 To ActiveDocument.Tables.Count
    Select Case IdxTable
        Case 3, 5, 7, 10
        ' do nothing
        Case Else
            Set mytable = ActiveDocument.Tables(IdxTable)
            With mytable
               .PreferredWidth = 97.5
               .PreferredWidthType = wdPreferredWidthPercent
               .Columns(2).Width = CentimetersToPoints(3.1)
               .Columns(3).Width = CentimetersToPoints(3.1)
               .PreferredWidth = 97.5
               .PreferredWidthType = wdPreferredWidthPercent
                For IdxRow = 2 To .Rows.Count
                    For IdxCol = 2 To 3
                        Set c = .Cell(IdxRow, IdxCol)
                        c.Range.ParagraphFormat.TabStops.Add Position:=CentimetersToPoints(1.7) _
                            , Alignment:=wdAlignTabDecimal, Leader:=wdTabLeaderSpaces
                    Next
                Next
            End With
    End Select
Next
End Sub

Open in new window

Regards
0
 

Author Closing Comment

by:AndreasHermle
ID: 39850055
Great job, as always, thank you very much for your great and professional support.

Regards, Andreas
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question