Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

new VBA help filling a table with data in word 2003 1

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
here is all I have so far
Code:
    ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=2, NumColumns:= _
        9, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
        wdAutoFitFixed
    With Selection.Tables(1)
        If .Style <> "Table Grid" Then
            .Style = "Table Grid"
        End If
        .ApplyStyleHeadingRows = True
        .ApplyStyleLastRow = True
        .ApplyStyleFirstColumn = True
        .ApplyStyleLastColumn = True
    End With

How can put text in a particular cell?
Say Row 1, Col 1 is the word "Sample #"
under that are some dates like
1829-001
1829-002
1829-003

and make the top row background color light gray

DougP, MCP, A+
[r2d2] I Built my own R2D2
I love this site and all you folks that helped me over the years!
 
A starting point:
Code:
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=4, NumColumns:=9 _
 , DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed
With Selection.Tables(1)
  If .Style <> "Table Grid" Then
    .Style = "Table Grid"
  End If
  .ApplyStyleHeadingRows = True
  .ApplyStyleLastRow = True
  .ApplyStyleFirstColumn = True
  .ApplyStyleLastColumn = True
  .Cell(1, 1).Range.Text = "Sample #"
  .Cell(2, 1).Range.Text = "1829-001"
  .Cell(3, 1).Range.Text = "1829-002"
  .Cell(4, 1).Range.Text = "1829-003"
End With

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 



Hi,

Dates? These do not look like dates to me...

Code:
    With Selection.Tables(1)
      .Cells(1,1).value = "1829-001"
    End With

Skip,

[glasses] To be safe on the [red]FOURTH[/red],
Don't take a [red]FIFTH[/red] on the [red]THIRD[/red]
Or you might not come [red]FORTH[/red] on the [red]FIFTH[/red]
[red][highlight blue]FORTH[/highlight][/red][white][highlight red]WITH[/highlight][/white] [tongue]
 




sorry its
Code:
.Cell(1, 1).Range = ""

Skip,

[glasses] To be safe on the [red]FOURTH[/red],
Don't take a [red]FIFTH[/red] on the [red]THIRD[/red]
Or you might not come [red]FORTH[/red] on the [red]FIFTH[/red]
[red][highlight blue]FORTH[/highlight][/red][white][highlight red]WITH[/highlight][/white] [tongue]
 
No they are not Dates, I started the thread and changed my mind half way through but forgot to edit out "Dates" They are Sample Numbers.
Anyway

Do you know how to make the top row light Gray color?

DougP, MCP, A+
[r2d2] I Built my own R2D2
I love this site and all you folks that helped me over the years!
 




Turn on your macro recorder, shade the heading, and check it out.

Skip,

[glasses] To be safe on the [red]FOURTH[/red],
Don't take a [red]FIFTH[/red] on the [red]THIRD[/red]
Or you might not come [red]FORTH[/red] on the [red]FIFTH[/red]
[red][highlight blue]FORTH[/highlight][/red][white][highlight red]WITH[/highlight][/white] [tongue]
 
simply add this before the End With:
.Rows(1).Shading.BackgroundPatternColor = wdColorGray25

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
yeah baby
have a star


DougP, MCP, A+
[r2d2] I Built my own R2D2
I love this site and all you folks that helped me over the years!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top