hi,
i try to add tables to a word doc, the problem is, the next table is always add befor the last one
looks like this:
Do While textfile.AtEndOfStream <> True
txt = textfile.ReadLine
a = Split(txt,vbTab)
If a(1)= "@@" Then
i=1
j=j+1
objDoc.Tables.Add objRange,1,5
'here i tried to count the tables by another var, but doesn't work e.g.:Set objTable = objDoc.Tables(j)
Set objTable = objDoc.Tables(1)
objTable.Range.Font.Size = 10
'objTable.AutoFitBehavior(0)
objTable.Columns(1).PreferredWidth = 150
objTable.Columns(2).PreferredWidth = 200
objTable.Columns(3).PreferredWidth = 60
objTable.Columns(4).PreferredWidth = 60
objTable.Columns(5).PreferredWidth = 250
'Add Headline with special formatting
objTable.Rows.Add()
objTable.Rows(i).HeadingFormat=True
objTable.Rows(i).HeadingFormat=1
objTable.Rows(i).Range.Font.Size = 16
objTable.Cell(i, 1).Range.Text = a(0)
objTable.Rows(i).Range.Font.Bold = False
objTable.Rows(i).Cells.Merge
'add column headline for each table
i=i+1
objTable.Rows.Add()
objTable.Rows(i).HeadingFormat=True
objTable.Rows(i).HeadingFormat=1
objTable.Rows(i).Range.Font.Size = 14
objTable.Rows(i).Range.Font.Bold = False
objTable.Cell(i, 1).Range.Text = "ELEMENT"
objTable.Cell(i, 2).Range.text = "LABEL"
objTable.Cell(i, 3).Range.text = "USER"
objTable.Cell(i, 4).Range.text = "DATE"
objTable.Cell(i, 5).Range.text = "COMMENT"
'objRange.ParagraphFormat.Alignment = 0
i=i+1
Else
objDoc.Tables(1).Rows.Add()
objTable.Rows(i).AllowBreakAcrossPages = False
objRange.ParagraphFormat.Alignment = 0
objTable.Rows(i).Range.Font.Bold = False
objTable.Cell(i, 1).Range.Text = a(0)
objTable.Cell(i, 2).Range.text = a(1)
objTable.Cell(i, 3).Range.text = a(2)
objTable.Cell(i, 4).Range.text = a(3)
objTable.Cell(i, 5).Range.text = a(4)
i=i+1
End If
Loop
i try to add tables to a word doc, the problem is, the next table is always add befor the last one
looks like this:
Do While textfile.AtEndOfStream <> True
txt = textfile.ReadLine
a = Split(txt,vbTab)
If a(1)= "@@" Then
i=1
j=j+1
objDoc.Tables.Add objRange,1,5
'here i tried to count the tables by another var, but doesn't work e.g.:Set objTable = objDoc.Tables(j)
Set objTable = objDoc.Tables(1)
objTable.Range.Font.Size = 10
'objTable.AutoFitBehavior(0)
objTable.Columns(1).PreferredWidth = 150
objTable.Columns(2).PreferredWidth = 200
objTable.Columns(3).PreferredWidth = 60
objTable.Columns(4).PreferredWidth = 60
objTable.Columns(5).PreferredWidth = 250
'Add Headline with special formatting
objTable.Rows.Add()
objTable.Rows(i).HeadingFormat=True
objTable.Rows(i).HeadingFormat=1
objTable.Rows(i).Range.Font.Size = 16
objTable.Cell(i, 1).Range.Text = a(0)
objTable.Rows(i).Range.Font.Bold = False
objTable.Rows(i).Cells.Merge
'add column headline for each table
i=i+1
objTable.Rows.Add()
objTable.Rows(i).HeadingFormat=True
objTable.Rows(i).HeadingFormat=1
objTable.Rows(i).Range.Font.Size = 14
objTable.Rows(i).Range.Font.Bold = False
objTable.Cell(i, 1).Range.Text = "ELEMENT"
objTable.Cell(i, 2).Range.text = "LABEL"
objTable.Cell(i, 3).Range.text = "USER"
objTable.Cell(i, 4).Range.text = "DATE"
objTable.Cell(i, 5).Range.text = "COMMENT"
'objRange.ParagraphFormat.Alignment = 0
i=i+1
Else
objDoc.Tables(1).Rows.Add()
objTable.Rows(i).AllowBreakAcrossPages = False
objRange.ParagraphFormat.Alignment = 0
objTable.Rows(i).Range.Font.Bold = False
objTable.Cell(i, 1).Range.Text = a(0)
objTable.Cell(i, 2).Range.text = a(1)
objTable.Cell(i, 3).Range.text = a(2)
objTable.Cell(i, 4).Range.text = a(3)
objTable.Cell(i, 5).Range.text = a(4)
i=i+1
End If
Loop