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 / August 2006

Tip: Looking for answers? Try searching our database.

Table Info in a Word Document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
NJ - 16 Aug 2006 17:33 GMT
I have a Word 2003 document that has four tables in it. Using VBA; how do I
get information on the 3rd table (e.g. table3.column1.width)
Dave Lett - 16 Aug 2006 18:41 GMT
Hi,

You can use something like the following:

Dim oCol As Column
Set oCol = ActiveDocument.Tables(3).Columns(1)

MsgBox PointsToInches(oCol.Width)

HTH,
Dave

>I have a Word 2003 document that has four tables in it. Using VBA; how do I
> get information on the 3rd table (e.g. table3.column1.width)
NJ - 16 Aug 2006 22:29 GMT
Dave,
I am trying to hide a column with the following code but it still displays a
column between column 4 and 6 and its width is 0.8666
How do I completely hide a column?

ActiveDocument.Tables(2).Columns(5).PreferredWidth = 0
ActiveDocument.Tables(2).LeftPadding = 0
ActiveDocument.Tables(2).RightPadding = 0

> Hi,
>
[quoted text clipped - 10 lines]
> >I have a Word 2003 document that has four tables in it. Using VBA; how do I
> > get information on the 3rd table (e.g. table3.column1.width)
Dave Lett - 17 Aug 2006 13:29 GMT
Hi,

I don't know everything, but I feel okay about two answers that I have about
this issue (neither of which you'll like, I guess):

1) I don't think you can fully hide a table's column in Word. The width of
the column will always be there to some degree (at least in my testing,
which has NOT been exhaustive)
2) If you really want to hide a column, use Excel.

Sorry, I'm not trying to be glib, I just don't think you can do what you're
trying to do with Word.

Another method to do this would be to hide the contents of the column:
Dim oTbl As Table
Dim oCol As Column
Dim oRng As Range

Set oTbl = ActiveDocument.Tables(3)
Set oRng = oTbl.Range
Set oCol = oTbl.Columns(1)
oCol.Select
Selection.Font.Hidden = True

Convert the table to text:
oTbl.ConvertToText Separator:=wdSeparateByTabs

Replace a hidden tab, with some other character:
With oRng.Find
   .ClearFormatting
   .Text = "^t"
   .Font.Hidden = True
   With .Replacement
       .ClearFormatting
       .Text = ","
   End With
   .Execute Replace:=wdReplaceAll
End With

Covert the text back to a table:
oRng.ConvertToTable Separator:=wdSeparateByTabs

So, then, you end up with the column hidden, but now you have a table with
no borders and you're left with the problem of "adding" the column back.

HTH,
Dave

> Dave,
> I am trying to hide a column with the following code but it still displays
[quoted text clipped - 21 lines]
>> >do I
>> > get information on the 3rd table (e.g. table3.column1.width)
Ed - 17 Aug 2006 14:36 GMT
Dave and NJ - My Table dialog just told me the measurement has to be at
least 0.02 inches.  If you do that and hide one of the side borders, it
looks like the column isn't there.

Ed

> Hi,
>
[quoted text clipped - 69 lines]
>>> >do I
>>> > get information on the 3rd table (e.g. table3.column1.width)
 
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.