Public Sub CreateExcelFile() Dim excelApp As Excel.Application Dim excelBook As Workbook Dim excelSheet As Worksheet Dim excelRange As Range Dim oEmail As SendEmail Set excelApp = New Excel.Application If Err.Number <> 0 Then Set excelApp = CreateObject("Excel.Application") End If Set excelBook = Workbooks.Add Set excelSheet = Excel.Worksheets.Add(Before:=Worksheets(1)) If Val(excelApp.Application.Version) >= 8 Then Set excelSheet = excelApp.ActiveSheet Else Set excelSheet = excelApp End If With excelSheet.Cells.Font .Name = "Arial" .Size = 8 End With ' Write field header With excelSheet .Cells(1, 1) = "Clientname" ' code to insert more text here End With excelSheet.Columns("A:L").EntireColumn.AutoFit excelBook.SaveAs strFilename excelBook.Close excelApp.Quit Set excelSheet = Nothing Set excelBook = Nothing Set excelApp = Nothing ' send email Set oEmail = New SendEmail With oEmail .SendTo = "" .Subject = "Testing" .Body = "test" .Attachments strFilename .Show End With End Sub