Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-02-2022, 01:14 AM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help Please, IF with Selected Paragraph Format & Left Indent with First Line Indent Windows 10 Help Please, IF with Selected Paragraph Format & Left Indent with First Line Indent Office 2019
Competent Performer
Help Please, IF with Selected Paragraph Format & Left Indent with First Line Indent
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 200
Cendrinne is on a distinguished road
Red face Help Please, IF with Selected Paragraph Format & Left Indent with First Line Indent

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
Where is my faux pas in my script?

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
Reply With Quote
  #2  
Old 03-06-2022, 04:28 AM
macropod's Avatar
macropod macropod is offline Help Please, IF with Selected Paragraph Format & Left Indent with First Line Indent Windows 10 Help Please, IF with Selected Paragraph Format & Left Indent with First Line Indent Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,373
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 03-06-2022, 04:36 AM
macropod's Avatar
macropod macropod is offline Help Please, IF with Selected Paragraph Format & Left Indent with First Line Indent Windows 10 Help Please, IF with Selected Paragraph Format & Left Indent with First Line Indent Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,373
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #4  
Old 03-06-2022, 04:42 AM
Guessed's Avatar
Guessed Guessed is offline Help Please, IF with Selected Paragraph Format & Left Indent with First Line Indent Windows 10 Help Please, IF with Selected Paragraph Format & Left Indent with First Line Indent Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,161
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
Reply

Tags
advice, help me, left indent



Similar Threads
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
Help Please, IF with Selected Paragraph Format & Left Indent with First Line Indent Left indent 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

Other Forums: Access Forums

All times are GMT -7. The time now is 03:50 PM.


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