Next: 2.4 Getting Help about
Up: 2. Tutorial
Previous: 2.2 Locating COM Objects
  Contents
With the ProgID or the CLSID of an object, it's now possible to create
a new instance of it or to get a running instance. To do so, the
easiest way is to use the method CreateObject of the Lua API:
word = luacom.CreateObject("Word.Application")
assert(word)
word.Visible = true
If there is an already running instance of the object you want,
GetObject must be used to use it. The following code
illustrates this:
-- If there is an instance of Word(r) running,
-- it will end it
word = luacom.GetObject("Word.Application")
if word then
word:Quit()
word = nil
end
Fabio Mascarenhas de Queiroz
2005-06-06