在vb中应用microsoft excel object
然后用下面代码就行
还有其他功能可以到excel中录制宏
然后编辑宏什么都有
Dim objExcel As New Excel.Application
objExcel.Workbooks.Open "c:\1.xls"
objExcel.Visible = True
With objExcel.ActiveSheet
If Not IsNumeric(.Cells(1, 2).Value) Then
.Range("a2").Select
With ActiveCell.Characters(Start:=1, Length:=2).Font
.Name = "Times New Roman"
.FontStyle = "加粗"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 3
End With
End If
Exit Sub
If .Cells(1, 2).Value > 20 Or .Cells(1, 2) < 10 Then
With ActiveCell.Characters(Start:=1, Length:=2).Font
.Name = "Times New Roman"
.FontStyle = "加粗"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 3
End With
End If
End With