lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

Try wb:Worksheets(1) and ws:Cells(1,1).Value. LuaCOM follows the Lua
convention for method calls.

--
Fabio

On 8/12/06, David Manura <dm.gmane@math2.org> wrote:
Does anyone know why the last line here fails?

  -- test.lua
  require('luacom')
  excel = luacom.CreateObject("Excel.Application")
  excel.Visible = true
  wb = excel.Workbooks:Add()
  ws = wb.Worksheets(1)
  ws.Cells(1,1).Value = "test"

  COM exception:(.\src\library\tLuaCOM.cpp,398):Type mismatch.
  stack traceback:
        [C]: ?
        stdin:1: in main chunk
        [C]: ?

It works fine in JavaScript (cscript.exe):

  // test.js
  excel = WScript.CreateObject("Excel.Application");
  excel.Visible = true;
  wb = excel.Workbooks.Add();
  ws = wb.Worksheets(1);
  ws.Cells(1,1).Value = "test";

I tried this with luacom 1.3 in Lua 5.0.2 since luacom is slightly broken in Lua
5.1 as noted here: http://lua-users.org/lists/lua-l/2006-02/msg00571.html

--davidm