Excel dosyası yaratma


Sub CreateXLSFile()
    Dim excelApp, Wb1, Sh1, i
    Set excelApp = CreateObject("Excel.Application")
    Set Wb1 = excelApp.Workbooks.Add
    Set Sh1 = Wb1.Sheets(1)
    
    For i = 1 To 10
        Sh1.Cells(i, 1).Value = "row:" & i & ", column:1"
        Sh1.Cells(i, 2).Value = "row:" & i & ", column:2"
        Sh1.Cells(i, 3).Value = "row:" & i & ", column:3"
    Next
    Sh1.Range(Sh1.Cells(1, 1), Sh1.Cells(10, 3)).Select
    excelApp.Selection.Font.Size = 14
    excelApp.Selection.Font.Name = "Arial"
    excelApp.Selection.Font.Bold = True
    excelApp.Selection.Font.ColorIndex = 4
    excelApp.Selection.Interior.ColorIndex = 1
    Sh1.Range(Sh1.Columns(1), Sh1.Columns(3)).Select
    excelApp.Selection.EntireColumn.AutoFit
    Wb1.SaveAs "c:\xlsSample.xls"
    excelApp.Visible = True
End Sub