Specifications
OLE reference
Gallagher & Robertson Glink: API reference manual 155
Dim GL As Object
Set GL = CreateObject ("Glink.Auto")
GL.LoadConfig ("WSK.glinkconfig")
GL.ProcessLine = True
GL.GWConnect ("ggate", "phoenix")
GL.GParam = "0"
GL.ScriptCommand ("Rece '-^$03';Sndl 'Gkrm F';GetF FTRA
'*CLP;msg';GPar '1'")
While GL.GParam = "0"
DoEvents
Wend
Selection.Paste
The routine shown is the basis for a Word 7 macro, and as such is written in
VBA.
It starts off by defining the Glink object. The first statement creates an instance
of Glink. We then load a suitable configuration file with LoadConfig, and
connect to our host with GWConnect (the example was run over a Ggate
connection). Now we set the Gparam property to "0" (Gparam is equivalent to
the script global parameter and is useful for script synchronization as it is in
DDE applications). The script command we execute first waits for the host
prompt, then sends a file transfer request and then brings down the file into the
clipboard. Finally it sets the global script parameter to "1".
Invoking the ScriptCommand method will only start the process described, while
the VBA routine can carry on doing whatever it likes in the meantime. However,
we want to wait until the file is here, so the next three statements do just that.
Finally we quite simply paste in the contents of the clipboard (which now
contains the contents of the GCOS file) at the current insertion point.
A point to note is that Glink does not initially connect to the host until the
Automation controller client requests it via the Connect, GWConnect or script
command methods.