Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-24-2021, 10:14 AM
eduzs eduzs is offline VBA to align left cells table Windows 10 VBA to align left cells table Office 2019
Expert
VBA to align left cells table
 
Join Date: May 2017
Posts: 266
eduzs is on a distinguished road
Default VBA to align left cells table

I need to align left the text in column 2 from line 2 to the last line in a word table, how can I do that?


Thanks all.
Reply With Quote
  #2  
Old 06-24-2021, 03:51 PM
Guessed's Avatar
Guessed Guessed is offline VBA to align left cells table Windows 10 VBA to align left cells table Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,185
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

This will probably fail if you have merged cells in your table but it will get you started
Code:
Sub Macro1()
  Dim iRow As Integer, iRows As Integer
  With Selection.Tables(1)
    iRows = .Rows.Count
    For iRow = 2 To iRows
      .Cell(iRow, 2).Range.ParagraphFormat.Alignment = wdAlignParagraphLeft
    Next iRow
  End With
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 06-25-2021, 09:35 AM
eduzs eduzs is offline VBA to align left cells table Windows 10 VBA to align left cells table Office 2019
Expert
VBA to align left cells table
 
Join Date: May 2017
Posts: 266
eduzs is on a distinguished road
Default

Thanks Guessed, works fine!
I also did this using select.

Code:
Dim oTbl As Table
Set oTbl = ActiveDocument.Tables(1)
With oTbl
    .Range.Columns(2).Select
    Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
    .Cell(1, 2).Select
    Selection.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
End With
Set oTbl = Nothing
Just another question, is there a way to set a range of vertical cells from the start cell to the end cell, instead of one left to right and top to bottom?

Code:
Set oRng = ActiveDocument.Range(Start:=oTbl.Cell(2, 2).Range.Start, End:=oTbl.Cell(5, 2).Range.End)
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to align left cells table Align...both left and right? supersimu Word 1 01-25-2014 02:05 AM
VBA to align left cells table Unable to vertically center align texts in table cells? tinfanide Word 3 11-24-2013 06:37 AM
VBA to align left cells table How to Sort Table Cells from Left to Right tamaracklodge Word Tables 4 03-04-2013 04:00 AM
VBA to align left cells table How to align page to left side instead of centre ghumdinger Word 2 08-18-2011 10:15 AM
How do I align image at ABSOLUTE top left of a table cell? shnoozin Outlook 0 07-22-2011 03:30 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:59 AM.


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