![]() |
#1
|
|||
|
|||
![]()
Hi all.
I have a table with n lines. The first column has fixed width and contains short paragraphs (mostly composed by a single word). I use the following code to automatically shrink paragraphs which are too long (reducing characters size and spacing), until they fit into a single line. The problem is that the code works only on the odd lines of the table, while the even ones remains untocuhed. Why? How can I solve? Thanks for your help. ------------ Dim EOC As String Dim p As Paragraph Dim rng As Range Dim chkspace As Single EOC = Chr(13) & Chr(7) ' this combination marks the end of a cell For Each p In ActiveDocument.Paragraphs If p.Range.Text Like "*" & EOC Then Set rng = p.Range 'commenting out next line will select the whole cell rng.MoveEnd wdCharacter, -1 rng.Select 'MsgBox "Found paragraph at end of cell..." Else Set rng = p.Range 'commenting out next line will select the whole cell rng.MoveEnd wdCharacter, -1 rng.Select 'MsgBox "Found paragraph NOT at end of cell..." With p.Range While .Information(wdFirstCharacterLineNumber) <> .Characters(Len(.Text)).Information(wdFirstCharact erLineNumber) 'compare the line number of the first character of the paragraph and the line number of the last a = .Font.Size 'MsgBox (A) rng.Font.Size = a - 0.5 If .Information(wdFirstCharacterLineNumber) <> .Characters(Len(.Text)).Information(wdFirstCharact erLineNumber) Then If rng.Font.Spacing > -0.3 Then rng.Font.Spacing = rng.Font.Spacing - 0.05 If .Information(wdFirstCharacterLineNumber) <> .Characters(Len(.Text)).Information(wdFirstCharact erLineNumber) Then If rng.Font.Spacing > -0.3 Then rng.Font.Spacing = rng.Font.Spacing - 0.05 End If End If Wend End With End If Next p |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
jlw15931 | Mail Merge | 1 | 02-24-2015 05:03 AM |
![]() |
Andy Pilkington | Word | 2 | 10-10-2014 12:36 AM |
![]() |
Joey Cheung | Word Tables | 1 | 08-12-2014 05:15 PM |
![]() |
VBLearner | Word VBA | 1 | 03-09-2014 08:42 PM |
![]() |
dennist77 | Word | 1 | 10-29-2013 11:39 PM |