Dim App As New MSExcel.Application Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("D:\Report.xls") Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1) Dim Rg As MSExcel.Range = Ws.Range("A1") Rg.Value = "Foxtable操控Excel全攻略" Rg.Font.Size = 50 '把字体放大 Rg.EntireColumn.AutoFit '自动调整列宽 Rg.EntireRow.AutoFit '自动调整行高 App.Visible = True
如果要调整工作表全部单元格的大小,可以使用Cells属性。如:
Dim App As New MSExcel.Application Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("D:\Report.xls") Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1) Dim Rg As MSExcel.Range = Ws.Cells Rg.EntireColumn.AutoFit '自动调整列宽 Rg.EntireRow.AutoFit '自动调整行高 App.Visible = True