Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-11-2016, 01:27 PM
Marco Marco is offline table and code accidentally working only on odd rows Windows Vista table and code accidentally working only on odd rows Office 2007
Novice
table and code accidentally working only on odd rows
 
Join Date: Apr 2015
Posts: 15
Marco is on a distinguished road
Default table and code accidentally working only on odd rows

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
table and code accidentally working only on odd rows I want to add multiple rows into my document but I can not figure out the code jlw15931 Mail Merge 1 02-24-2015 05:03 AM
table and code accidentally working only on odd rows Header Rows in Tables Not Working Andy Pilkington Word 2 10-10-2014 12:36 AM
table and code accidentally working only on odd rows Is it possible to copy non-contiguous rows of a Table and paste them as a separate Table in Word? Joey Cheung Word Tables 1 08-12-2014 05:15 PM
table and code accidentally working only on odd rows VBA Code to take data from a table in word document and place it in a summary table VBLearner Word VBA 1 03-09-2014 08:42 PM
table and code accidentally working only on odd rows Grouping table rows to prevent individual rows from breaking across pages dennist77 Word 1 10-29-2013 11:39 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:34 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