Error with Borders.LineStyle = wdLineStyleSingle

A

Alex St-Pierre

Hi,
I have a program that run in excel with automation and create a docword with
tables. Sometimes, the program but at the tbl.Cell(i,
j).Borders(wdBorderBottom).LineStyle = wdLineStyleSingle, the border is not
created. So, the program stop at the following line (.LineWidth =
wdLineWidth025pt). Sometimes, it works, sometimes it doesn't. It's
unpredicable.. Any idea?
Thanks!
Alex
tbl is a word.table
oXlRng is an ExcelRange that contains the table
oRange = docWord.Range(0,0)
oXlRng.Copy
oRange.PasteExcelTable LinkedToExcel:=False, WordFormatting:=False,
RTF:=False 'Even this line bug sometimes.. It's not very stable...

For i = 1 To tbl.Rows.Count
For j = 1 To iCell(i)

TimeA = Timer - Time1 - TimeA - TimeB - TimeC - TimeE
With oXlRng.Cells(i, r(i, j))
With .Borders(xlEdgeTop)
If .LineStyle = xlContinuous Then
tbl.Cell(i, j).Borders(wdBorderTop).LineStyle =
wdLineStyleSingle
If .Weight = xlThin Then
tbl.Cell(i, j).Borders(wdBorderTop).LineWidth =
wdLineWidth025pt
ElseIf .Weight = xlMedium Then
tbl.Cell(i, j).Borders(wdBorderTop).LineWidth =
wdLineWidth150pt
End If
End If
End With
With .Borders(xlEdgeBottom)
If .LineStyle = xlContinuous Then
tbl.Cell(i, j).Borders(wdBorderBottom).LineStyle =
wdLineStyleSingle 'Line not always created
If .Weight = xlThin Then
tbl.Cell(i, j).Borders(wdBorderBottom).LineWidth =
wdLineWidth025pt
ElseIf .Weight = xlMedium Then
tbl.Cell(i, j).Borders(wdBorderBottom).LineWidth =
wdLineWidth150pt
End If
End If
End With
 

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