How to find table width in word

Any one can tell me how to find out the table width in percentage using word vba macro.
Krishna MTechnical AssociatAsked:
Who is Participating?
 
GrahamSkanRetiredCommented:
Thanks for the suggestion, Paul.

Krishna, does this help?
Sub GetWidth()
    Dim sumwidth As Single
    Dim TheWidth As Single
    Dim vcol As Column
    
    With ActiveDocument.PageSetup
        TheWidth = .PageWidth - .LeftMargin - .RightMargin
    End With
    
    sumwidth = 0
    For Each vcol In ActiveDocument.Tables(1).Columns
        sumwidth = sumwidth + vcol.Width
    Next
    Debug.Print "Width ="; sumwidth; "points"; ", (" & Format(sumwidth / TheWidth, "#0.00%"); ")"
End Sub

Open in new window

0
 
aikimarkCommented:
sumwidth=0
for each vCol in ActiveDocument.Tables(1).columns
    sumwidth=sumwidth + vcol.width
next
debug.print sumwidth

Open in new window

0
 
Krishna MTechnical AssociatAuthor Commented:
it's giving value in points. But I want to get the width as percentage(%)
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
GrahamSkanRetiredCommented:
Percentage of what?
0
 
Paul SauvéRetiredCommented:
@Graham
i think he means % of width between margins!
0
 
Krishna MTechnical AssociatAuthor Commented:
Thanks for everyone.

Special thanks to GrahamSkan. Its working fine
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.