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 / March 2007

Tip: Looking for answers? Try searching our database.

Table Macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Al - 09 Mar 2007 13:11 GMT
This may be asking too much but here goes

I need a macro to insert a Paragraph Mark at the end of each table cell

I have tried looking for examples of code but so far no luck

Thanks
Al
Jay Freedman - 09 Mar 2007 15:26 GMT
> This may be asking too much but here goes
>
[quoted text clipped - 5 lines]
> Thanks
> Al

If any of the following is still a mystery, post back and point to what you
don't understand.

Sub AddParaToEachCell()
   Dim myTable As Table
   Dim myCell As Cell
   Dim myRange As Range

   For Each myTable In ActiveDocument.Tables
       For Each myCell In myTable.Range.Cells
           Set myRange = myCell.Range
           With myRange
               ' move the end of the range to
               ' the spot between the last
               ' character and the cell marker
               .MoveEnd wdCharacter, -1

               ' collapse the range to that spot
               .Collapse wdCollapseEnd

               ' insert a paragraph mark
               .Text = vbCr
           End With
       Next
   Next
End Sub

Signature

Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

 
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.