Excel中的字体如何编程让它居中

解决方案 »

  1.   


    Range("F2").Select
        ActiveCell.FormulaR1C1 = "nihao"
        With ActiveCell.Characters(Start:=1, Length:=5).Font
            .Name = "Times New Roman"
            .FontStyle = "常规"
            .Size = 12
            .Strikethrough = False
            .Superscript = False
            .Subscript = False
            .OutlineFont = False
            .Shadow = False
            .Underline = xlUnderlineStyleNone
            .ColorIndex = xlAutomatic
        End With
        Range("F2").Select
        With Selection
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlBottom
            .WrapText = False
            .Orientation = 0
            .AddIndent = False
            .ShrinkToFit = False
            .MergeCells = False
        End With
      

  2.   

    声明部分    
    Set ex = CreateObject("Excel.Application")
        flag = True
        Set ex = CreateObject("Excel.Application")
        Set exwbook = Nothing
        Set exsheet = Nothing
        Set exwbook = ex.Workbooks().Add
        Set exsheet = exwbook.Worksheets("sheet1")
      

  3.   


    Columns(1).HorizontalAlignment = xlCenter         第一列居中        .HorizontalAlignment = xlRight
            .HorizontalAlignment = xlLeft
            .HorizontalAlignment = xlCenter