Excel Application
Hi All!!!!
I am making excel file and i have to write the data on it, so want to call it throug function...
My source is below...
Private Sub Command1_Click()
Dim abc As File, wb As excel.Workbook, app1 As excel.Application, isexist As Double
Private Sub Command1_Click()
Set app1 = CreateObject("Excel.Application")
Set wb = app1.Workbooks.Add
Dim fsys As New Scripting.FileSystemObject
ActiveWorkbook.Worksheets(1).Select
ActiveWorkbook.Worksheets(1).Name = "Daily Sale Report"
ActiveSheet.Cells(3, 3) = "CUSTOMER SALES REPORT AS ON '" & Date & "'"
app1.Visible = True
WriteSheet2
Set abc = fsys.GetFile("c:\temp\sfc.xls")
abc.Attributes = Normal
fsys.DeleteFile ("c:\temp\sfc.xls")
wb.SaveAs FileName:="C:\temp\sfc.xls", FileFormat:=xlNormal, CreateBackup:=True
app1.ActiveWorkbook.Save
End Sub
Private Sub WriteSheet2()
ActiveWorkbook.Worksheets.Add
ActiveWorkbook.Worksheets(2).Select
ActiveWorkbook.Worksheets(2).Name = "Sheet Two"
ActiveSheet.Cells(3, 0) = "Sheet Two"
ActiveSheet.Cells(3, 1) = "Sheet Two"
ActiveSheet.Cells(3, 2) = "Sheet Two"
ActiveSheet.Cells(3, 3) = "Sheet Two"
ActiveSheet.Cells(3, 4) = "Sheet Two"
ActiveSheet.Cells(3, 5) = "Sheet Two"
ActiveSheet.Cells(3, 6) = "Sheet Two"
End Sub
I am getting the error in BOLD expression
when calling function how can i handle it give me some idea....
Exception is - Runtime Error '1004':
Application-Defined or object defined Error.
Thanks in Advance!!! :)
DPK..
__________________
DPK..
|