利用VB如何 读取和设置 Excel中表单的 单元格格式
希望高手们不吝赐教!

解决方案 »

  1.   

    先在Excel中用宏记录一下不就知道了
      

  2.   

    比如我要设置单元格的文本控制为自动换行,有边框等等!
    则代码如下:    With Selection
            .HorizontalAlignment = xlGeneral
            .VerticalAlignment = xlBottom
            .WrapText = True
            .Orientation = 0
            .AddIndent = False
            .ShrinkToFit = False
            .MergeCells = False
        End With
        Selection.Borders(xlDiagonalDown).LineStyle = xlNone
        Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With Selection.Borders(xlEdgeLeft)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeRight)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
    代码很简单,怎么得来的,就是楼上所说用excel的宏生成的!
      

  3.   

    你只需要学习一下EXCEL生成的宏代码就全都会了.
      

  4.   

    如果已知单元格的格式,用VB创建Excel,又如何设置刚刚生成的Excel表单中单元格的格式呢?
      

  5.   


    先在Excel中录制宏看一下代码稍为改动就可以用到VB中