Bloccato VBA Word Table style bug?

  • giovedì 5 aprile 2012 08:04
     
      Contiene codice

    Hi all,

    I have created a macro, attached to a button on my word document, which added a new row to the top of a table and changes the colour of the bottom line of the row to light grey. However there appears to be a problem which I think is a bug in either the language or word itself which meant that the part of my function which colours the bottom of the row only works once!

    I did create a work around which was to actually call the style function twice (but it had to apply a different colour, even though only one of the colours are actually applied). Can someone have a look and see if it is something silly im doing, or do you see the same problem?

    Private Sub NewEntry_Click()
    'Select first row
    ActiveDocument.Tables(1).Rows.First.Range.Select
    
    'Insert row at the top
    Selection.InsertRowsAbove
    
    'Format the cell so that the bottom line style is light grey, near invisible
    With ActiveDocument.Tables(1).Rows.First.Range
        'This is done twice as I believe there is a bug in word which means that if you only
        'put it once then it only works once. However, I found that if you do it twice, actually
        'each needs to be different hence the two different colours, then it appears
        'to work correctly, and actually only one of the colours still appears!
        .Borders(wdBorderBottom).Color = wdColorGray10
        .Borders(wdBorderBottom).Color = wdColorGray05
    End With
    End Sub

    Cheers,

    Chris

Tutte le risposte