A list of products available on this site
Documentation for XtraMania's xtras
Prices and links to the online store
Xtras, PDFs, samples
Have a question? Ask us!
Contacts
Logo. www.xtramaina.com  
Home Search E-mail
VbScriptXtra Samples/Excel

ActiveCompanionSet xtras for Macromedia Director

Typing something in Excel

This handler will run Excel application (if any) create new workbook and print simple message in the first cell of the first sheet.

on testExcel
  -- Creating a new instance of Microsoft Excel
  excel=xtra("VbScriptXtra").CreateObject("Excel.Application")
  
  -- Checking whether object is created
  if not objectP(excel) then
    alert "Failed to create Excel.Application:"&RETURN&excel
    exit
  end if
  
  -- Setting application's window params
  excel.visible=true
  excel.DisplayFullScreen=false
  excel.left=100
  excel.top=100
  excel.width=400
  excel.height=300
  
  -- Creating new workbook
  doc=excel.workbooks.add()
  
  -- Getting access to the first work sheet of the newly created work book
  sheet=doc.worksheets(1)
  
  -- Arranging work book window
  excel.windows.arrange()
  
  -- Setting the value of the left-top cell
  -- Extra parentheses required for Director 7
  (sheet.cells(1,1)).Value="Hello Excel!"
  
  -- Setting the font style of the left-top cell
  (sheet.cells(1,1)).Style.Font.Bold=true
  
  -- Setting the width and height of the cell using range property
  -- Square brackets may be used with single argument
  sheet.range["A1:A1"].rowHeight=64
  sheet.range["A1:A1"].columnWidth=16
end

Where to find more info about Excel?

Microsoft Excel contains rather large help system, which contains just everything about Excel. Look at Visual Basic for Excel topics, which describes Excel data model, objects, methods and properties you can use.
Make sure you have installed this part of the help system, since it may not be included in typical installation.

VbScriptXtra provides autodocumentation feature allowing you to see what you can do with particular object instance. Just create a recordset object and type in Messages window:
put interface(excel)
put interface(excel.WorkBooks)
put interface(sheet)
put interface(sheet.cells(1,1))

ObjectBrowser xtra - autodocumentation companion for VbScriptXtra - will show all available Excel interfaces, methods, properties and enumerations.

ObjectBrowser xtra is a part of ActiveCompanionSet. It is available to Download.

Site homeSearchContact author © Eugene Shoustrov. www.xtramania.com