lua-users home
lua-l archive

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


BTW, there is a new version of LuaCom at:
 http://www.tecgraf.puc-rio.br/~rcerq/luacom/pub/beta2/

It works with Lua 4.

--Renato

On Thursday, December 5, 2002, at 03:47 PM, Mark Stroetzel Glasberg wrote:

Jean Claude Morlier wrote:
I try to use LuaCom to interact with Excel.
Is there some exemple on how to do this ?
Where can I found some documentation about excel COM Objects ?

I do not have examples of LuaCOM with Excel, but you can look up the
IDL in the OLE/COM Object Viewer or in MSDN.

I am sending an example of LuaCOM with PowerPoint, it should be
quite similar.

Regards,
Mark

--
-- PowerPoint LuaCOM control
--
-- Mark Stroetzel Glasberg
-- 28/10/2002
--

PPT = {}

function PPT:Open()
  local process = create_process{cmd="C:\\Program Files\\Microsoft
Office\\Office10\\POWERPNT.EXE /AUTOMATION"}
  sleep(3)
  self.ppt = luacom_GetObject("Powerpoint.Application")
end

function PPT:GetObject()
  self.ppt = luacom_GetObject("Powerpoint.Application")
  local prs = self.ppt.Presentations
  self.pr = prs:Item(1) -- Filename is also valid. Ex:
"D:\\mark\\test.ppt"
  self.view = self.pr.SlideShowWindow.View
end

function PPT:Close()
  self.ppt:Quit()
end

function PPT:ListFiles(dir)
  local fs = self.ppt.FileSearch
  fs.LookIn = dir
  fs.FileName = "*.ppt"
  fs.FileType = 5
  fs.SearchSubFolders = 1
  local n = fs:Execute()
  local files = fs.FoundFiles
  local i = 1
  while n >= i do
    print("<option value='"..files.Item(i).."'><br>")
    print(files.Item(i))
    i = i + 1
  end
end

function PPT:Filename(filename)
  self.ppt.Visible = 1
  self.pr = self.ppt.Presentations:Open(filename)
end

function PPT:Start()
  local pr = self.pr
  if pr == nil then
    print("Cannot Start presentation without a filename")
    return
  end
  pr.SlideShowSettings.StartingSlide = 1
  pr.SlideShowSettings.EndingSlide = pr.Slides.Count
  local cur = pr.SlideShowSettings:Run()
  self.view = cur.View
end

function PPT:First()
  self.view:First()
end

function PPT:Last()
  self.view:Last()
end

function PPT:Next()
  self.view:Next()
end

function PPT:Previous()
  self.view:Previous()
end


--
|\/|ark Stroetzel Glasberg
mark@tecgraf.puc-rio.br

Computer Engineer

Tecgraf/PUC-Rio
URL:  http://www.tecgraf.puc-rio.br/~mark
Tel:  55 21 2512-5984 ext. 116
Fax:  55 21 2259-2232