QTP Forum
Shopmotion


Working with Excel Objects using VBscript Empty
Search
 
 

Display results as :
 


Rechercher Advanced Search

Poll
Keywords

Latest topics
September 2019
MonTueWedThuFriSatSun
      1
2345678
9101112131415
16171819202122
23242526272829
30      

Calendar Calendar

Affiliates
free forum

Similar topics

    Working with Excel Objects using VBscript

    Go down

    Vote if this topic was useful to you

    Working with Excel Objects using VBscript Vote_lcap0%Working with Excel Objects using VBscript Vote_rcap 0% 
    [ 0 ]
    Working with Excel Objects using VBscript Vote_lcap0%Working with Excel Objects using VBscript Vote_rcap 0% 
    [ 0 ]
    Working with Excel Objects using VBscript Vote_lcap100%Working with Excel Objects using VBscript Vote_rcap 100% 
    [ 1 ]
    Working with Excel Objects using VBscript Vote_lcap0%Working with Excel Objects using VBscript Vote_rcap 0% 
    [ 0 ]
     
    Total Votes : 1

    Working with Excel Objects using VBscript Empty Working with Excel Objects using VBscript

    Post by Gajre on Thu Jun 21, 2012 2:35 am

    'Working with Excel Object
    'Create an Microsoft Excel Object using VBScript
    Set ExcelObject = CreateObject("Excel.Application")
    ExcelObject.visible = True
    ExcelObject.WorkBooks.Add 'Adds a workbook to an excel object
    ExcelObject.Sheets(1).Cells(1,1).value = "Text in the Cell" 'Writes a text to a particular cell in the excel object

    'Open Microsoft file using VBScript
    Set ExcelObject = CreateObject("Excel.Application")
    ExcelObject.visible = True
    ExcelObject.Workbooks.Open("c:\excelsheet.xls",Default, False)
    ExcelObject.Sheets(1).Cells(1,1).value = "Text to be entered"
    ExcelObject.Activeworkbook.SaveAs("d:\excelsheet.xls") 'Using Save As

    'Save the Excel Workbook
    ExcelObject.Activeworkbook.save

    'Get the Number of Rows used in the Excel sheet
    RowCount = ExcelObject.ActiveWorkbook.Sheets(1).UsedRange.Rows.count
    msgbox "Number of rows used in the excel sheet "& RowCount

    'Get the Number of Columns used in the Excel sheet
    ColumnCount = ExcelObject.ActiveWorkbook.Sheets(1).UsedRange.Columns.count
    msgbox "Number of columns used in the excel sheet "&ColumnCount

    'Change the sheet name of the Excel workbook
    ExcelObject.Activeworkbook.Sheets(1).Name = "NameOftheFirstSheet"
    ExcelObject.Activeworkbook.Sheets(2).Name = "NameoftheSecondSheet"

    'Get the Sheet Name of the Excel workbook
    FirstSheetName = ExcelObject.Activeworkbook.Sheets(1).Name
    msgbox "Name of the first sheet"&FirstSheetName

    SecondSheetName = ExcelObject.Activeworkbook.Sheets(2).Name
    msgbox "Name of the second sheet"&SecondSheetName
    Gajre
    Gajre
    Admin

    Posts : 37
    Join date : 2012-06-17
    Age : 36
    Location : Hyderabad

    View user profile https://qtpelearning.forumotion.com

    Back to top Go down

    Back to top

    - Similar topics

     
    Permissions in this forum:
    You cannot reply to topics in this forum