![]() |
|
![]() |
|
Thread Tools | Display Modes |
#1
|
||||
|
||||
![]()
Hello Pros,
I again beg for your help, guidance. I feel I'm so close to the correct script. I can't figure out what I'm doing wrong. I wish to Select most cells in the first column, which are align to the left. IF the Left Indent = 0 AND First Line Indent = 0 Then .Left Indent = 0.17 .First Line Indent = -0.11 (which both combination has a reality of 0.06 Indentation) Else .Left Indent = 0.36 .First Line Indent = 0.11 (which both combination has a reality of 0.25 Indentation) What is happening to me, the first selected cell, ok corrects it, but since it's still selected, then it does the Else line, so all the selected cells, becomes 0.25. I have so many tables to fix (and that is one of my big problems). Here is the full script I've created: Code:
Sub test2_T1fr_If_Cell_0v00_put0v06() Dim aTbl As Table, oCel As Cell Set aTbl = Selection.Tables(1) Selection.SelectCell With Selection.ParagraphFormat .RightIndent = InchesToPoints(0) .Alignment = wdAlignParagraphLeft '.FirstLineIndent = InchesToPoints(-0.11) .OutlineLevel = wdOutlineLevelBodyText .CharacterUnitLeftIndent = 0 .CharacterUnitRightIndent = 0 '.CharacterUnitFirstLineIndent = 0 End With Selection.SelectCell With Selection.ParagraphFormat If .LeftIndent = InchesToPoints(0) And .FirstLineIndent = InchesToPoints(0) Then .LeftIndent = InchesToPoints(0.17) 'Reality = 0.06 .FirstLineIndent = InchesToPoints(-0.11) Else .LeftIndent = InchesToPoints(0.36) 'Reality = 0.25 .FirstLineIndent = InchesToPoints(-0.11) End If End With 'Next oCel Set oCel = Nothing: Set aTbl = Nothing On Error GoTo 0 End Sub Please, any guidance. I would be so grateful for insights ![]() *********************** (second issue, is a request for an advice = I wish to do a copy and paste each table numbers which a macro formated to the needs I have. However, each tables has at least 3 rows where it's full. So for example, 3 columns for 20 rows, then 1 full row (merge I guess), then another 5-6 rows, then 1 full row again, etc. So my issue is I'm trying to paste my formated numbers on the two last columns but I can't select the columns I need due to these anoying merge cells. So I have to select each row that is full, and split them in either 3 columns or more, depending on the tables. When you have over 200 tables, I feel like crying. Any advice you could share with me) Cendrinne |
#2
|
||||
|
||||
![]()
Simple:
Code:
Sub Demo() Application.ScreenUpdating = False Dim r As Long With Selection If .Information(wdWithInTable) = False Then Exit Sub With .Tables(1) For r = 1 To .Rows.Count With .Cell(r, 1).Range.ParagraphFormat If .LeftIndent = InchesToPoints(0) And .FirstLineIndent = InchesToPoints(0) Then .LeftIndent = InchesToPoints(0.17) Else .LeftIndent = InchesToPoints(0.36) End If .FirstLineIndent = InchesToPoints(-0.11) End With Next End With End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
||||
|
||||
![]()
And, for the second problem:
Code:
Sub Demo() Application.ScreenUpdating = False Dim Tbl As Table, r As Long For Each Tbl In ActiveDocument.Tables With Tbl For r = 1 To .Rows.Count If .Rows(r).Cells.Count = 3 Then With .Cell(r, 3).Range 'Do whatever with the 3rd cell End With End If Next End With Next Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#4
|
||||
|
||||
![]()
You need to go back and look at the code from the earlier thread. It is a slippery slope to apply direct formatting to your content when you 'should' be using styles to make things consistent. All you need to do is one line to apply the desired style.
With the above code you have gone back to using Selection but perhaps you aren't sure what you selected. What was it that you wanted the macro to format. Your code is selecting a cell which might contain more than one paragraph. Are you trying to format every paragraph in every cell?
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
![]() |
Tags |
advice, help me, left indent |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to indent first line from second paragraph of every heading? | indra059 | Word | 3 | 02-22-2022 08:20 PM |
![]() |
gabelman | Word | 3 | 10-04-2018 11:51 AM |
Difference between first line Indent and Left Indent | kingston123 | Word | 3 | 09-25-2018 02:47 PM |
Don't indent the fist line of the first paragraph after a style change | Inspirement | Word | 1 | 04-08-2012 05:30 AM |
No indent first line of first paragraph of new section | RogRhein | Word | 0 | 10-10-2010 09:52 AM |