wdAdjustFirstColumn [Word 2003]

M

Macro''er :)

Can someone please help me with a macro to create two column tables with the
first column being wdAdjustFirstColumn and second column to be
wdAutoFitWindow? When I post online, I don't want the first column to adjust
and I want the second column to stretch across the page.

I appreciate any help.

Thank you so much!
 
P

Pesach Shelnitz

Hi,

With following macro you can set the width of the first column, and the
second column will stretch across the page. Note that I included the
DefaultTableBehavior parameter only so that the table would have visible
borders when it is created.

Sub CreateTable()
Dim myTable As table
Dim colWidth As Variant

colWidth = InputBox("Enter the width of the first column in centimeters.")
If IsNumeric(colWidth) = False Then
MsgBox "A valid number was not entered."
Exit Sub
End If
Set myTable = _
ActiveDocument.Tables.Add(Range:=Selection.Range, NumRows:=3, _
NumColumns:=2, DefaultTableBehavior:=wdWord9TableBehavior)
With myTable
.PreferredWidthType = wdPreferredWidthAuto
.Columns(1).Width = CentimetersToPoints(colWidth)
.Columns(2).Width = 2 * .Columns(2).Width - _
.Columns(1).Width
End With
End Sub
 
M

Macro''er :)

Hi Pesach,

Thank you so much for your quick respond.

Can you please help me create the script for, let's say that I want two
columns (no visible borders). The first column to be 10% width (fixed - do
not want this to adjust) and second column to be wdAutoFitWindow 80% in
width. I also want the macro to not have the input box.

I thank you in advance again for your help!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top