'----WORKING WITH EXCEL
'CREATING OBJECT FOR EXCEL
'Optional explicit
'Dim objXls,fso,exclfile,sheet1,sheet2,existingsheet
'
'
'file_path="f:\testApp.xls"
'Set objXls= createobject("Excel.application")
''mAKING EXCEL FILE VISIBLE,SO THAT IT OPENS ELSE IT WILL DO OPERATION BACK END
'objXls.Visible=false
'
''---- it will check whether the file exist in the path,if not it will create a file else it will delete and create a new file.
'Set fso= createobject("Scripting.filesystemobject")
'
'If not fso.FileExists(file_path) Then
'set myxls=objXls.Workbooks.Add
'else
''delete the file and ccreate a new workbook
'fso.DeleteFile file_path
'set myxls=objXls.Workbooks.Add
'End If
'
''---creating the excel file
'Set exclfile=objXls.Workbooks.Add
'
'
''ADDING SHEET1 TO EXCEL
'set sheet1=exclfile.Sheets.Add
'sheet1.Name ="SystemTest"
''ADDING SHEET2 TO EXCEL
'set sheet2=exclfile.Sheets.Add
'sheet2.Name ="RegresstionTest"
'
''delete SystemTest sheet
'sheet2.Delete
'
''deleting existing sheet
'Set existingsheet=exclfile.sheets("sheet1")
'existingsheet.delete
'
'
'sheet1.Cells(2,3).value="city"' writing on cells
'
'sheet1.Cells(5,5).value="=Hyperlink("&chr(34)&"f:\xls\temp.png"&chr(34)&","&chr(34)&"click"&chr(34)&")"'--here we are adding hyperlink image to ecel cell(5,5)
'msgbox sheet1.Cells(2,3).value
'
'
'
'' if u want to override the data in cells
'objXls.DisplayAlerts=false
'exclfile.SaveAs "f:\testApp.xls"'--------------2003
'exclfile.SaveAs "f:\testApp.xlsx"'-------------------2007
'exclfile.Close'--close the excel file
'objXls.Quit '--quit the excel application
'
'
'calling a function using below function name
'readData
'writeData
'
No comments:
Post a Comment