Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-22-2021, 07:27 AM
gmaxey gmaxey is offline How to script most table column in word document? Windows 10 How to script most table column in word document? Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default


Nancy,


I think Andrew had a slight glitch in his msgbox string. Try:
Code:
Sub TestTables()
  Dim i As Integer, x As Integer, iTbl As Integer, sOthers As String
  For i = 1 To ActiveDocument.Tables.Count
    If ActiveDocument.Tables(i).Columns.Count > x Then
      x = ActiveDocument.Tables(i).Columns.Count
      iTbl = i
      sOthers = ""
    ElseIf ActiveDocument.Tables(i).Columns.Count = x Then
      sOthers = sOthers & i & ", "
    End If
  Next i
  If sOthers <> "" Then sOthers = "Other tables with same column count are: " & sOthers
  MsgBox "The table with the most columns is " & iTbl & vbCr + vbCr _
   & x & " Columns." & vbCr + vbCr & sOthers
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #2  
Old 03-22-2021, 12:38 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline How to script most table column in word document? Windows 10 How to script most table column in word document? Office 2019
Competent Performer
How to script most table column in word document?
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 200
Cendrinne is on a distinguished road
Default Thanks Greg (it's getting better).....

Gregggggggg, Hello

So glad to hear from you And thank you for providing a little twik.

However, for the love of me, I don't know why, it say's on the first line:
The Table with the most columns is 5
space
9 Columns.

I'm wondering, where is it getting the 5 from???

But it's ok, it will be a challenge for me to try to figure it out. Like a puzzle.

I want to thank you both from the bottom of my heart, cause it was a pain in the butt to scroll, to see which one that had the most columns. So already, this will help.

If I figure out the ''5'', I'll let you know. But please don't give me the answer, but maybe just ''hint'' where to look to fix it up, if it's taking too long for me to answer

But give me time, I'm still at work. Was just curious what it was said about the 5

Have a great one

Last edited by Cendrinne; 03-22-2021 at 06:08 PM.
Reply With Quote
Reply

Tags
help please, most table column



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to add final touches to merged document, after running MailMergeToDoc script NicB Word VBA 1 09-02-2020 05:47 PM
How to generate a word document with a table-script valdavaux Word 1 09-17-2017 03:32 PM
Is it possible to put a formula in a table column header to define the name of the column? JacquesW Excel 3 05-08-2017 08:00 AM
VBA to search each row of a word table column Marrick13 Word VBA 7 11-17-2014 04:33 AM
How to script most table column in word document? two column word document. plato Word 1 08-06-2010 04:02 AM

Other Forums: Access Forums

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