怎么在vb里控制excel单元格的宽度?

RakerCarter 2003-06-03 02:25:00
我使用以下语句来建立excel表格,可有的单元格的字节太长,需要调节格子的宽和高。请问要怎么写属性?最好能自动调整。
Dim direct As String

Dim i As Integer
Dim j As Integer
Dim ex As Object
Dim exwbook As Object
Dim exsheet As Object

CommonDialog1.DefaultExt = "xls"
CommonDialog1.ShowSave
direct = CommonDialog1.FileName

Set ex = CreateObject("Excel.Application")
Set exwbook = Nothing
Set exsheet = Nothing
Set exwbook = ex.Workbooks().Add
Set exsheet = exwbook.Worksheets("sheet1")

ex.range("a2").value="....."
...........

With ex.Range("A2:j7").Borders
.LineStyle = 1
.Weight = xlThin
.ColorIndex = 1
End With

exwbook.SaveAs direct
'退出excel
ex.Quit
...全文
107 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

807

社区成员

发帖
与我相关
我的任务
社区描述
VB 多媒体
社区管理员
  • 多媒体
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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