Private Sub createAndSaveExcelSheet(ByRef lRS As ADODB.Recordset, lDate As Date, ByRef lXLapp As Excel.Application)
Dim lXLwb As Excel.Workbook
Dim lXLws As Excel.Worksheet
Dim fso As New FileSystemObject
Dim lICount As Integer
Set lXLapp = New Excel.Application
lXLapp.Visible = False
Set lXLwb = lXLapp.Workbooks.Add
Set lXLws = lXLwb.ActiveSheet
lXLws.Rows(6).CopyFromRecordset lRS
Dim intcol As Integer
MsgBox "excel sheet open"
lXLws.Cells(5, 1) = "Card No"
lXLws.Cells(5, 2) = "Name"
lXLws.Cells(5, 3) = "Emp Code"
lXLws.Cells(5, 4) = "Department"
For intcol = 1 To 5
lXLws.Cells(5, intcol).Font.Size = 12
lXLws.Cells(5, intcol).Font.Bold = True
Next
MsgBox "doing autofit"
For lICount = 1 To lRS.Fields.count
lXLws.Columns.AutoFit
Next lICount
MsgBox "autofit done"
lXLws.Cells(1, 1).Font.Size = 18
lXLws.Cells(1, 1) = "SWIPE CARD REPORT GENERATED ON " & VBA.Date & " at " & VBA.Time
lXLws.Cells(3, 1).Font.Size = 16
lXLws.Cells(3, 1) = "People absent on " & lDate
MsgBox "parent stuff"
lXLapp.Parent.Windows(lXLwb.Name).Visible = True
MsgBox "switch off alerts to avoid overwrite dialog box by the excel application"
'switch off alerts to avoid overwrite dialog box by the excel application
lXLapp.DisplayAlerts = False
MsgBox "alert off and saving now"
--> lXLwb.SaveAs (App.Path & "\" & VBA.Format(lDate, "mmddyyyy"))
lXLapp.DisplayAlerts = True
lXLwb.Close
Set lXLwb = Nothing
Set lXLws = Nothing
Set lXLapp = Nothing
MsgBox "create and save excel done"
End Sub
all the code is working fine till the msgbox" alert off and saving now"
the problem is coming while i try to save the excel sheet. i have marked with an arrow. this error is coming i=on the pc where
vb is not installed.
please help me to overcome this error.