vb,建excel有不明白的地方,求注释
Dim lRow As LongExcel 注释
Dim sXLSPath As String
Dim MyExcel As New Excel.Application
Dim MyBook As Excel.workbook
Dim MySheet As Excel.worksheet
Screen.MousePointer = 11
sXLSPath = appdisk & "maindata.xls" 'appdisk为路径
Open sXLSPath For Output As #1 '求注释
Close #1
Set MyExcel = CreateObject("excel.application")
Set MyBook = MyExcel.Workbooks.Open(sXLSPath)
Set MySheet = MyExcel.ActiveSheet
MySheet.Range("A1:O1").Select '求注释
With MyExcel.Selection.Interior '求注释
.ColorIndex = 15
.Pattern = xlSolid
End With
Open sXLSPath For Output As #1
sXLSPath = appdisk & "maindata.xls" 'appdisk为路径
MySheet.Range("A1:O1").Select
With MyExcel.Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
MyExcel.Selection.Interior.ColorIndex = 15
MyExcel.Selection.Interior.Pattern = xlSolid
MySheet.Range("A1:O1").Select语句,使到"A1:O1"单元格被选择,所以Selection指的就是"A1:O1"单元格。Interior这个单词表示内部,意思是通过这个对象下面的属性调整单元格的格内的样式(与之区分的就是还有边框的样式,文本的样式之类的)。
所以不要误解我上面说的例如“Selection指的就是‘A1:O1’单元格”中所说的“‘A1:O1’单元格”是一个单元格,其实是很多个单元格的组合。
[解决办法]
Open sXLSPath For Output As #1 '以二进制打开maindata.xls文件,在你这好象没有什么用,打开后又马开关闭了
MySheet.Range("A1:O1").Select '选择A1:O1范围,应是列头,程序自动完成,不需要手动去选择
With MyExcel.Selection.Interior '上面选择的对象
.ColorIndex = 15 '选择灰色填充列头
.Pattern = xlSolid '设置该区域的内部图案,xlSolid表示纯色