     
 Microsoft Excel 10.0 Object Library
 (      2002 )

            C

Public xlApp As Excel.Application
Public xlBook As Excel.Workbook

Sub CreateNewWorkBooks()

Set xlApp = CreateObject("Excel.Application")
xlApp .SheetsInNewWorkbook = 1     '     

Set xlBook = xlApp.Workbooks.Add	'  
xlApp.Windows(1).ActiveSheet.Name = "sheet"   '   

xlBook.SaveAs FileName:="C:\file_name.xls"	' 
xlApp.Quit	

Set xlBook = Nothing
Set xlApp = Nothing

End Sub

---------------------------------------------
 

xlBook.Save      '               - 1

xlBook.SaveAs FileName:="C:\file_name.xls"	'      

xlBook.Close saveChanges:=True	'      
'                

xlBook.Saved = True

------------------------------------------
    

xlApp.Visible = True
'         

-------------------------------------------
 Common Dialog   

Components : 
- Microsoft Common Dialog Control 6.0
(   CommonDialog1   )

CommonDialog1.CancelError = True
On Error GoTo ErrHandler

CommonDialog1.FileName = ""
CommonDialog1.Filter = "Excel files: ( *.xls ) |*.xls|"
CommonDialog1.ShowOpen
If CommonDialog1.FileName = "" Then Exit sub
If Dir(CommonDialog1.FileName) = "" Then Exit Sub
Set xlBook= Workbooks.Open(CommonDialog1.FileName)
Application.Visible = True
..................
..................

xlBook.Close
	'     

xlBook.Close saveChanges:=True	'    
Set xlBook = Nothing
ErrHandler:
' User pressed Cancel button.
   Exit Sub

-------------------------------------------
 Common Dialog   

CommonDialog1.CancelError = True
On Error GoTo ErrHandler

CommonDialog1.FileName = "C:\file_name.xls"
CommonDialog1.Filter = "Excel files: ( *.xls ) |*.xls|"
CommonDialog1.ShowSave
If CommonDialog1.FileName = "" Then Exit sub
..................
..................

xlBook.SaveAs FileName:= CommonDialog1.FileName
Set xlBook = Nothing
ErrHandler:
' User pressed Cancel button.
   Exit Sub

------------------------------------------
    

CommonDialog1.CancelError = True
On Error GoTo ErrHandler

CommonDialog1.FileName = ""
CommonDialog1.Filter = "Excel files: ( *.xls ) |*.xls|"
CommonDialog1.ShowOpen
If CommonDialog1.FileName = "" Then Exit Sub
If Dir(CommonDialog1.FileName) = "" Then Exit Sub
Excel.Workbooks.Open (CommonDialog1.FileName)
Application.Visible = True
..................
..................

Excel.Workbooks.Close
ErrHandler:
' User pressed Cancel button.
   Exit Sub

-------------------------------------------
    

Public xlSheet As Excel.Worksheet

Set xlSheet = xlBook.Worksheets.Add	'  
xlSheet.Name = "sheet_name"	'   

-------------------------------------------
  

    xlApp.DisplayAlerts = False
    Worksheets("sheet_name").Delete
    xlApp.DisplayAlerts = True
        
--------------------------------------------
  

Cells(Row, Column)

xlSheet.Cells(1, 2).Value = "Welcome"	'      
' 
xlSheet.Cells("A2").Value = "Welcome"
' 
xlSheet.Range("A2").Value = "Welcome"
-------------------------------------------

 :
      
      
 xlSheet
 
Worksheets(1)       

Worksheets("Sheet")         

    
xlSheet.Range("A1:H11").Font.Size = 12
Worksheets(3).Range("A1:H11").Font.Size = 12
Worksheets("Sheet").Range("A1:H11").Font.Size = 12

-------------------------------------------
 

xlSheet.Range("A2").Font.Size = 12	' 
xlSheet.Range("A2").Font.Name =  "Times New Roman"	'  
xlSheet.Range("A2").HorizontalAlignment = xlCenter	' 
xlSheet.Range("A2").WrapText = True	'   
xlSheet.Range("A2").VerticalAlignment = xlVAlignCenter	' 
xlSheet.Range("A2").Borders.Weight = xlThin	'  

         
ActiveWorkbook.Styles("Normal").Font.ColorIndex = 3
 
ActiveWorkbook.Styles("Normal").Font.Color = RGB(0, 0, 255)

   Normal
         
For i = 1 To ActiveWorkbook.Styles.Count
    Worksheets(1).Cells(i, 1) = ActiveWorkbook.Styles(i).Name
Next

           
ActiveWorkbook.Styles("Normal").Font.Bold = True

  
With ActiveWorkbook.Styles.Add(Name:="MyStyle")
    .Font.Size = 12
    .Font.Bold = True
    .Font.Name = "Times New Roman"
    .Borders(xlEdgeTop).Weight = xlThin
    .Borders(xlEdgeLeft).Weight = xlThin
    .Borders(xlEdgeRight).Weight = xlThin
    .Borders(xlEdgeBottom).Weight = xlThin
End With

    
xlSheet.Range("B2:B10").Style = "MyStyle"

 
Worksheets("sheet_name").Cells(1, 1).NumberFormat = "###,##0.00"

-------------------------------------------
     

Worksheets("sheet_name").Range("A1:H10").Value = "Welcome"

Worksheets("sheet_name").Range(Worksheets("sheet_name").Cells(1, 1), Worksheets("sheet_name").Cells(10, 8)).Value = "Welcome"

 
With Worksheets("sheet_name")
	.Range(.Cells(1, 1),.Cells(10, 8)).Value = "Welcome"
End With

 
Dim c1, c2 As Variant
Set c1 = Worksheets("sheet_name").Cells(1, 1)
Set c2 = Worksheets("sheet_name").Cells(10, 8)
Worksheets("sheet_name").Range(c1, c2).Value = "Welcome"

      
Worksheets("sheet_name").Range("A1:H10").Font.Size = 12

xlsheet.Range("A2", "H11").Font.Size = 12

-------------------------------------------
  
xlSheet.Cells(1, 1).ColumnWidth = 15

  
xlSheet.Range("A1").RowHeight = 20

-------------------------------------------
 
Worksheets("sheet_name").Range("C11:C12").Merge

-------------------------------------------
 

xlSheet.Range("A1").Value = 1
xlSheet.Range("A2").Value = 2
xlSheet.Range("A3").Value = 3

xlSheet.Range("A4").Formula = "=SUM(A1:A3)"
xlSheet.Range("A5").Formula = "=AVERAGE(A1:A3)"

-------------------------------------------
( / * - + )    

xlSheet.Range("C1").Value =  (xlSheet.Range("A1").Value ) * (xlSheet.Range("B1").Value)

-------------------------------------------
      

xlSheet.Protect Password:="123", Scenarios:=True

-------------------------------------------
  

      
xlSheet.Move after:=Sheets(Sheets.Count)	
'    Sheets.Count

        
Sheets(Array("Sheet2", "Sheet4")).Move before:=Sheets(1)

-------------------------------------------
      

For i = 1 To Worksheets.Count
   If Worksheets(i).Name = "sheet_name"  Then        
      '           
      ..............
      ..............
      Exit For
   End If
Next i


-------------------------------------------
      

Worksheets.Add Count:=2, before:=Sheets(1)
'          

-------------------------------------------
         

Sheets.Add after:=Sheets(2), Type:=xlChart

-------------------------------------------
     

xlSheet.Range("a1:a10").Sort Key1:=Range("a1")

-------------------------------------------
            

Worksheets(2).Range("A1:H12").Copy
Worksheets(1).Range("A1").PasteSpecial (xlPasteAll)	'    -   
Worksheets(1).Range("A1").Select


-------------------------------------------
 

xlSheet.Range("A4").Formula = "=sum(A1:A3)"

-------------------------------------------

  

xlSheet.Cells(2, 2).Value = 1
xlSheet.Cells(3, 2).Value = 2
xlSheet.Range("B2:B3").AutoFill Destination:=xlSheet.Range("B4:B10"), Type:=xlLinearTrend

-------------------------------------------
   

xlsheet.Range("A1").EntireRow.Delete
xlsheet.Range("A1").EntireColumn.Delete

-------------------------------------------
    
xlsheet.Range("A2").EntireRow.Insert
xlsheet.Range("A2:A5").EntireRow.Insert
 
xlsheet.Range("B2").EntireColumn.Insert

-------------------------------------------
  
    

xlsheet.Columns(2).Hidden = True
xlsheet.Rows(3).Hidden = True

---------------------------------------------------
       

xlApp.Windows(1).DisplayRightToLeft = True    '       
xlApp.Windows(1).DisplayGridlines = False	'    
xlApp.Windows(1).DisplayFormulas = False	'   
xlApp.Windows(1).DisplayHeadings = False	'     
xlApp.Windows(1).DisplayHorizontalScrollBar = False	'    
xlApp.Windows(1).DisplayVerticalScrollBar = False	'    
xlApp.Windows(1).DisplayWorkbookTabs = False	'    



