
How to Create 2 column table and continue adding rows
Hi Tim
Try this. It will add text to a document and then convert it into a table.
Sometimes as faster to do it this way around.
'------------------------------------
Dim sFont As Variant
Dim oRng As Range
Dim oTbl As Table
For Each sFont In Application.FontNames
With Selection
.Font.Name = sFont
.TypeText sFont & vbTab & sFont & vbCr
End With
Next
Set oTbl = ActiveDocument.Range.ConvertToTable _
(Separator:=wdSeparateByTabs, NumColumns:=2)
oTbl.Sort FieldNumber:=2
oTbl.Columns(2).Select
Selection.Font.Name = "Times New Roman"
Selection.Collapse wdCollapseStart
--
Anna Bohman
Bra Utbildning AB, Sweden
Quote:
> I am trying to create a word document for a friend who wants to be able to
> open a specific document and, upon being opened, populate the document
with
> a 2 column table, and one row for every font in the system, and first
column
> have the font name in its own font, and the second column be plain
readable
> text as to the name of the font.
> I am pretty good at programming in VB but not VBA, and have no idea about
> document references.
> Can anyone give me any pointers?
> Heck, I got one working, but no table. I tried to use my fav TAB(##)
> function to tab over to another tabstop to create the "second column" but
it
> wasn't working, kept giving me an error about the index not correct?