Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual
Page 258

II. SOFTWARE GUIDES - 10. Driver488/W31
10F. Visual Basic
Personal488 User’s Manual, Rev. 3.0
II-243
During this process, some properties of the controls in your application were altered by Visual Basic.
These include the
LinkMode
and the
LinkTopic
. For more information on the use and meaning of
Link properties, consult your Visual Basic User Manual or Help system.
Run-Time Links
To create a run-time link:
1.
Your program must set itself up as a server via the
LinkMode
property. Your application may
have several forms, the form which contains the control that will supply the data must have its
LinkMode
property set to
SERVER
. This property can be set at design time by selecting the
LinkMode
property of your form and setting it to
SERVER
, or at run time by placing the following
command in the Load event service routine of your form:
LinkMode = SERVER
Note: The string
SERVER
is defined in
CONSTANT.TXT
which should be added to your project if
you wish to use it.
2.
To take your application out of server mode at run time, issue the following command in the
service routine of your choice:
LinkMode = NONE
3.
After your application has been setup as a server, the data in its controls is immediately accessible
to other applications.
4.
Start your application then launch Excel.
5.
Select a cell in the spreadsheet. We can now type in an application link by specifying: the
application to link, the form within the application, and the control within the form.
For example, if your application is named
PROJECT1
, with one form named
FORM1
, containing one
text box named
TEXT1
, type the following into a cell in your Excel spreadsheet:
=PROJECT1|FORM1!TEXT1
You have now formed a hot link Anything typed in text box
TEXT1
will appear in the spreadsheet
cell.
Posting Link Information
One drawback to this run-time linking approach is that a user of your program would need to know the
names of your application’s controls (like
TEXT1
) to complete the link. To eliminate this requirement,
your application can be programmed to post the link information in the clipboard. When programs like
Excel recognize the presence of this information in the clipboard, they enable a command called Paste
Link under their Edit menu. Paste Link will automatically place the string that we typed above into the
selected cell.
To program your application to post the link information:
1.
In your application, create a button or a menu item called Copy Link. Under your new control’s
Click event, type in the following:
ClipBoard.Clear
ClipBoard.SetText “PROJECT1|Form1!text1", &HBF00
The first line clears the present contents of the clipboard. The second line places the control
identifier which includes the application name, the form name and the control name, into the
clipboard and tags it as a link specifier via the last parameter (
&HBF00
).
2.
After starting your application, click the Copy Link control.
3.
Select a cell in the Excel spreadsheet and click the Paste Link item under the Edit menu. The
following string:
=PROJECT1|Form1!text1
is automatically placed in the cell completing the link.