View Single Post
 
Old 12-10-2011, 09:06 AM
tinfanide tinfanide is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default Excel VBA: Control Word Table and Set its properties

Code:
Sub testing()

Dim wrdApp As Word.Application
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Dim wrdDoc As Word.Document
Set wrdDoc = wrdApp.Documents.Add

Dim tbl As Word.Table
Set tbl = wrdDoc.Tables.Add(Range:=wrdDoc.Range, NumRows:=6, NumColumns:=1)

With tbl
    .Borders(wdBorderTop).LineStyle = wdLineStyleSingle
    .Borders(wdBorderRight).LineStyle = wdLineStyleSingle
    .Borders(wdBorderBottom).LineStyle = wdLineStyleSingle
    .Borders(wdBorderLeft).LineStyle = wdLineStyleSingle
    .Borders(wdBorderHorizontal).LineStyle = wdLineStyleSingle
    .Borders(wdBorderVertical).LineStyle = wdLineStyleSingle
    
For r = 1 To 6
    .Cell(r, 1).Range.Text = ActiveSheet.Cells(r, 1).Value
Next r

For s = 1 To 6 Step 2

    .Cell(s, 1).Range.ListFormat.ApplyListTemplateWithLevel ListTemplate:= _
    ListGalleries(wdNumberGallery).ListTemplates(1).ListLevels(1).StartAt
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' don't know how to set the properties
Next s
End With

End Sub
Can anyone give some hints? I can hardly find any tutorials to learn from online.
Reply With Quote