Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2006

Tip: Looking for answers? Try searching our database.

Newbie: How to select left cell in first row in a table?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Frank - 19 Oct 2006 11:05 GMT
I want to iterate through each table in a document and make som column
adjustments, see code below.

However, in order to make this work, I guess I need to select left cell in
first row in the table before performing a table column title search and the
column adjustment.

How do I select the left cell in first row in the table?

Regards

Frank Krogh

Sub AdjustTables()
 Application.ScreenUpdating = False
   For Each aTable In ActiveDocument.Tables
       aTable.AutoFitBehavior (wdAutoFitContent)
       FixTablesColumns
   Next aTable
 Application.ScreenUpdating = True
End Sub

Sub FixTablesColumns()
   Selection.Find.ClearFormatting
   With Selection.Find
       .Text = "given table column title"
       .Replacement.Text = ""
       .Forward = True
       .Wrap = wdFindContinue
       .Format = False
       .MatchCase = False
       .MatchWholeWord = False
       .MatchWildcards = False
       .MatchSoundsLike = False
       .MatchAllWordForms = False
   End With
   Selection.Find.Execute
   Selection.SelectColumn
   Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
   Selection.Columns.PreferredWidth = CentimetersToPoints(2.24)
   Selection.Find.ClearFormatting
   Selection.MoveLeft Unit:=wdCharacter, Count:=1

' other table column adjustments here ...

end sub
Jezebel - 19 Oct 2006 11:08 GMT
Dim pCell as Word.Cell

set pCell = aTable.Cells(1,1)

>I want to iterate through each table in a document and make som column
> adjustments, see code below.
[quoted text clipped - 43 lines]
>
> end sub
Frank - 19 Oct 2006 12:33 GMT
Thank you for the suggestion.

However, I get a run time error '438': Object doesn't support this property
or method, when I try this code:

Dim pCell As Word.Cell
 
 Application.ScreenUpdating = False
   For Each aTable In ActiveDocument.Tables
       aTable.AutoFitBehavior (wdAutoFitContent)
       Set pCell = aTable.Cells(1, 1)
       FixTableColumns
   Next aTable
 Application.ScreenUpdating = True

> Dim pCell as Word.Cell
>
[quoted text clipped - 47 lines]
> >
> > end sub
Tony Jollans - 19 Oct 2006 12:42 GMT
Use Cell instead of Cell*s*.

--
Enjoy,
Tony

> Thank you for the suggestion.
>
[quoted text clipped - 62 lines]
> > >
> > > end sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.