怎么在vb里控制excel单元格的宽度?
我使用以下语句来建立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