
Opens or creates a COM/OLE Automation object.
ObjectAccess(app.objname, create-flag)
(s) app.objname name of the desired object.
(i) create-flag @TRUE, it will create an instance of the object, and return a handle to it. @FALSE, it will fail and return an error.
(i) a special object handle to be used when referring to the object. See discussion in COM/OLE section.
ObjectAccess has been superceded with the function ObjectGet.
If there is already a running instance of the object specified by "app.objname", this function will return a handle to that object.
If there is not a running instance of the specified object, the behavior will depend on the value of 'create-flag':
If 'create-flag' == @TRUE, it will create an instance of the object, and return a handle to it.
If 'create-flag' == @FALSE, it will fail and return an error.
This function is similar to ObjectOpen, except that ObjectOpen always creates a new object and cannot be used to access an existing one.
See COM/OLE section for information on COM/OLE Automation.
types = "Doc Files|*.doc"
file = AskFilename("SelectFile", "C:\", types, "", 1)
wdGoToLine = 3
wdLine = 5
wdExtend = 1
wdCharacter = 1
If AppExist("winword.exe")
   oWORD = ObjectAccess("Word.Application", @FALSE)
   newWord = @FALSE
Else
   oWORD = ObjectOpen("Word.Application")
   newWord = @TRUE
EndIf
oDOCS = oWORD.Documents
oDOC = oDOCS.Open(file)
oWORD.visible=@TRUE
oActiveDoc = oWORD.activedocument
oSel=oWORD.selection
oSel.GoTo(wdGoToLine,1)
While @TRUE
   oSel.EndKey(:: Unit=wdLine, Extend=wdExtend)
   oSel.Copy
   line = ClipGet()
   Message("Line",line)
   oSel.MoveRight(:: Unit=wdCharacter, Count=1)
   If oSel.MoveRight == 0 Then Break
   oSel.MoveLeft(:: Unit=wdCharacter, Count=1)
   ; compensate for MoveRight
EndWhile
oActiveDoc.close()
ObjectClose(oSel)
ObjectClose(oActiveDoc)
ObjectClose(oDOC)
ObjectClose(oDOCS)
If newWord
   oWord.Quit
EndIf
ObjectClose(oWORD)
Exit