Microsoft Office Forums How do I run code on all cells in all tables?

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-04-2019, 02:57 AM
wido wido is offline How do I run code on all cells in all tables? Windows 10 How do I run code on all cells in all tables? Office 2016
Novice
How do I run code on all cells in all tables?
 
Join Date: Sep 2019
Posts: 4
wido is on a distinguished road
Default How do I run code on all cells in all tables?

Hi. Sorry for my noobness, but we all started as noobs at some point!
The following VBA code does its thing on only one cell. How can I edit it so that it does it on all cells?? Thank you so much.
Code:
Dim tbl As Table
For Each tbl In ActiveDocument.Tables
   With tbl
      .Range.Cells(1).WordWrap = True
      .Range.Cells(1).FitText = False
   End With
Next

Reply With Quote
  #2  
Old 09-04-2019, 04:50 AM
gmayor's Avatar
gmayor gmayor is offline How do I run code on all cells in all tables? Windows 10 How do I run code on all cells in all tables? Office 2016
Expert
 
Join Date: Aug 2014
Posts: 2,899
gmayor is just really nicegmayor is just really nicegmayor is just really nicegmayor is just really nice
Default

Code:
Dim tbl As Table
Dim oCell As Cell
    For Each tbl In ActiveDocument.Tables
        With tbl
            For Each oCell In .Range.Cells
                oCell.WordWrap = True
                oCell.FitText = False
            Next oCell
        End With
    Next tbl
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 09-04-2019, 05:32 AM
wido wido is offline How do I run code on all cells in all tables? Windows 10 How do I run code on all cells in all tables? Office 2016
Novice
How do I run code on all cells in all tables?
 
Join Date: Sep 2019
Posts: 4
wido is on a distinguished road
Default

Thank you gmayor!
That was super helpful!
And by the way, thank you for all the Word-related stuff you posted on your website, it was tremendously helpful to me and my office staff!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I run code on all cells in all tables? Can I repeat or self-populate cells/tables? pvh PowerPoint 6 05-05-2015 03:21 PM
How do I run code on all cells in all tables? VBA code to format a document containing tables rasika99 Word VBA 3 12-12-2014 04:16 AM
Tables in Powerpoint - Hiding Cells manisfeld PowerPoint 2 06-08-2014 08:17 PM
Tables not populating properly from code DepricatedZero Word VBA 1 06-04-2013 06:22 AM
Shading in Cells in Word Tables Cindy Word Tables 1 01-04-2013 02:38 PM


All times are GMT -7. The time now is 03:28 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft