在VB里怎样控制Excel的字体和颜色?急啊!

jazzyfree 2003-05-16 10:31:37
在VB里怎样控制Excel的字体和颜色?急啊!


程序中这样写,但第二行报错

Worksheet.Cells(iTO, 2).Select
Worksheet.Selection.Font.ColorIndex = 3 //此行报错“无此方法”

//Worksheet为Worksheets对象


在Excel的宏里这写是正确的,但在VB里报错,不知道怎样写是正确的?


在此先说声谢谢了! :)
...全文
391 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xinshou1979330 2003-06-14
  • 打赏
  • 举报
回复
学习
GHOSTSEA 2003-06-12
  • 打赏
  • 举报
回复
dim xlApp as new excel.application
……
xlapp.range("a1").font.color=vbRed
……
lihonggen0 2003-06-11
  • 打赏
  • 举报
回复

With Selection.Font
.Name = "华文行楷"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
web1999 2003-05-22
  • 打赏
  • 举报
回复
Range("a1", "b2").Select
With Range("a1", "b2").Font
.Name = Style_ExcelFontName
.FontStyle = "常规"
.Size = Style_ExcelFontSize
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With

2,463

社区成员

发帖
与我相关
我的任务
社区描述
VBA(Visual Basic for Applications)是Visual Basic的一种宏语言,是在其桌面应用程序中执行通用的自动化(OLE)任务的编程语言。
社区管理员
  • VBA
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧