Sub Init()
    Cells.Select
    With Selection.Font
        .Name = "宋体"   '要附的变量
        .Size = 9   '要附的变量
    End With
    With Application
        .ReferenceStyle = xlR1C1  'col use char or xltoright is use number
        .Selection.CurrentRegion.Columns.AutoFit
        .Selection.CurrentRegion.Rows.AutoFit
    End With
    Columns("A:B").Select
    Selection.NumberFormatLocal = "@" '文本格式
    With ActiveCell.Characters(Start:=1, Length:=4).Font
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
    End With
End Sub
我想用VB控制EXCEL的的字体,VB可否传变量给EXCEL中的宏??哪位用过阿?

解决方案 »

  1.   

    dim vba_name as string
    dim vba_size as integer sub form_load()
        vba_name ="宋体"
        vba_size =9
    end sub.....................
    With Selection.Font
            .Name = vba_name    '要附的变量
            .Size = vba_size   '要附的变量
        End With
      

  2.   

    我没写清楚!宏是写在EXCEL模版里的
        xlsheet.Activate '激活工作表
        xlBook.RunAutoMacros (xlAutoOpen) '运行EXCEL中的启动宏
    我想只要设好所有的值后,把所有的任务交给宏来完成
      

  3.   

    也可以把变量写到一个TXT文件中.在VBA中引用scripting Runtime,通过
    CreateObject("Scripting.FileSystemObject") 取出TXT 中的变量.
      

  4.   

    只要達到目的不就行了嗎?管他是不是在EXCEL的宏呢?