Sie sind auf Seite 1von 10

Appendix

TABLE OF
CONTENTS FOR
THIS MANUAL
Click in this box to see the Table
of Contents for this manual.

Using ReportSmith with


other applications

Appendix A

You can use ReportSmith with other Windows applications, combining your
work from several products into one application. ReportSmith supports this
function through Dynamic Data Exchange (DDE) and Object Linking and
Embedding (OLE). DDE lets you call ReportSmith from another application,
and vice versa. OLE lets you include objects from other applications in your
ReportSmith reports.
This appendix describes both methods (OLE and DDE), and presents
examples for each, including the following topics:

Using DDE

Initiating DDE conversations


Starting ReportSmith from another application
Sending menu commands to ReportSmith
DDE synchronization

Using OLE 2.0


Dragging information between applications

Using DDE
Dynamic Data Exchange (DDE) allows two Windows applications to
communicate by sending and receiving data and commands.
ReportSmith can be either a DDE client or a DDE server. A client application
makes requests of another Windows application. In turn, a server
application responds to requests from another application. Requests can
be commands or requests for specific data.
With ReportSmith, you can execute menu commands by Dynamic Data
Exchange (DDE) command from another Microsoft Windows application.
Appendix A, Using ReportSmith with other applications

171

DDE is a protocol for Microsoft Windows that enables two applications to


talk to each other. For example, using DDE, an application can tell
ReportSmith to open and print a report, leaving ReportSmith minimized.
This allows another application to present its user interface for printing
previously built reports.

Initiating DDE conversations


Two applications using DDE to pass commands are having a DDE
conversation. DDE establishes a channel between the two applications to
transmit information. As shown in the illustration below, the DDE client is
the application that initiates the conversation. The DDE server is the
application that responds to the DDE client. ReportSmith can function as a
client or a server.

Client

Sends DDE command

Server

Responds to DDE command

To begin a DDE conversation, your code must specify:


The name of the server to talk to (the application name.)
The topic of the conversation (the system or command topic.)
The items to be performed.
When ReportSmith receives a request for a conversation about a topic, it
opens a channel. Once you establish a DDE conversation, you cant change
topics or applications. To begin a conversation with a different server or with
the same server about a different topic, you must start a new conversation on
a different channel.
After a conversation has begun, the two applications exchange messages
concerning particular items. An item is usually a reference to a piece of data
in the topic. Items vary from topic to topic; each server recognizes different
topics. ReportSmith supports the System topic for passing menu commands.
It also supports the Command topic for passing ReportBasic commands.

Applications
Every Windows-based application that can participate in DDE conversations
has a unique application (or app) name. The table below shows the app
names for some common Windows applications:
Application

172

App name

ReportSmith

ReportSmith

Microsoft Access

MSAccess

Microsoft Excel

Excel

Program Manager

Progman

Users Guide

Application

App name

Word for Windows

WinWord

ReportSmith Runtime

RS_Runtime

Topics
A topic defines the subject of the DDE conversation and represents some unit
of data meaningful to the DDE server application. ReportSmith supports the
System topic and the Command topic, as well as user-defined topics.

Items
An item is a reference to a piece of data or, in ReportSmiths case, a command
to execute. For example, an item could be a menu command such as File|
Open or a ReportBasic command such as LoadReport.
Note

Strings used for the application name, topic, or item in a DDE conversation
arent case-sensitive.

Calling ReportSmith
To start ReportSmith from another application:

1 First you must start ReportSmith from within another application. For
example, the following VisualBasic code starts ReportSmith(minimized
and without focus):
x = Shell("c:\rptsmith\rptsmith.exe", 6)

2 You can now execute DDE conversations.


Note

Examples of this are shown in the following sections.

Calling another application


ReportSmith can act as a DDE client. Other Windows applications may be
called from a ReportSmith macro using the Report Basic language. The
commands used are listed below.
Report Basic Command

Important

Description

DdeExecute

Send a DDE execute command to a DDE server application.

DdePoke

Poke data to a DDE server application.

DdeRequest

Get data from a DDE server application.

Refer to the online Help for details on the commands used to call other
applications.

Appendix A, Using ReportSmith with other applications

173

Sending menu commands


The syntax for a DDE command in ReportSmith consists of the main menu
name, a vertical bar (|), the menu item, and, optionally, a list of parameters
enclosed within parenthesis.
The illustration below identifies the parts of a DDE command:

view|zoom ( )
Menu name
Command name

You can also specify the option you want to use in the DDE command. For
example, if you want your application to magnify the object in its window up
to 150%, you enter the DDE command as follows:
view|zoom(150)

Following are examples of some other commands:

File|Open(BASIC.RPT)
File|Close
File|Print
View|Zoom(150)

You can send a command to ReportSmith using the following VisualBasic


code examples.

DDE synchronization
You need to know when ReportSmith finishes executing the DDE command
if the client must wait until that process is complete. This is done by waiting
for the main application window to gain focus. The following VisualBasic
code demonstrates this.

' Use Windows API calls to detect when the report is finished loading.
RS_Window_Handle = FindWindow("SWAP:MAIN", "ReportSmith")
' Return if the ReportSmith window can't be found.
If RS_Window_Handle = 0 Then
MsgBox "ReportSmith Not Found"
Exit Sub
End If
Waiting = 0
While Waiting = 0
' Check if our main Window is Enabled it will be disabled
' until the report is loaded.
Waiting = IsWindowEnabled(RS_Window_Handle)
' Allow Windows to do its thing while we wait.
DoEvents
Wend

174

Users Guide

Using OLE 2.0


You can include information or objects created in other Windows
applications in your report with ReportSmiths linking and embedding
(OLE) features. For example, a ReportSmith report can contain a Lotus
worksheet, or a Microsoft Word document, or an Excel spreadsheet; these are
all examples of objects. To access a linked document within the application
it was created in, double-click an icon representing the object in your
report. For example, a report with an embedded Microsoft Word
document displays the Microsoft Word icon on the report. When you
double-click on the icon, the Word document appears.

Double-click the
icon to open the
associated file

The main difference between linking and embedding an object is where you
store the data. When you embed an object in a report you are inserting
information into that report. Embedded objects become a part of the report
itself. When you link an object to your report, the report stores just the
location of the object and displays a representation of the linked data such
as an icon. Linked objects are stored in a source file and retain a connection
to the original Windows application.
Use embedding to include information that becomes a part of the report and
is always available, even if the original source file is absent or moved. You
can also use embedding to include a file that may not always be available,
such as a file residing on a network.
Use linking to include data in your report that is maintained in a separate file
and to save space. The ReportSmith report will reflect any changes made to
the source file and always displays the last-saved version. Also, you can use
linking to include a very large file such as a video or sound object in your
report.

Embedding objects in a report


To embed an existing object from another application:

1 Create and save the object in its application.


2 Select the object, and, with the Copy command on the Edit menu, copy it
to the Clipboard.

Appendix A, Using ReportSmith with other applications

175

3 Return to ReportSmith by minimizing the application or clicking outside


the application window.
4 Select the Paste command on the Edit menu.
5 With the mouse, position the Object cursor within the header or footer
where you want to place the object.
6 Left-click the mouse. ReportSmith places the object where you clicked in
the report.
7 Double-click the header or footer if the object exceeds its boundaries. A
box with sizing handles surrounds the header or footer.
8 Click and drag one of the corner handles until you can see the entire object
within the header or footer boundaries, then release the mouse button.
To create an object and embed it in a report:

1 Select the Object command on the Insert menu. The Insert Object dialog
box appears.
ReportSmith can accept and embed objects from any applications youve
installed on your workstation that fully support OLE. In this example,
well insert a Microsoft Graph into the page header of our report.

2 Double-click the application you want to use to create the object from the
Object Type list box. Alternatively, select the application you want to use
and click the OK button.
The Object cursor appears.

3 With the mouse, position the Object cursor within the header or footer
where you want to place the object.
4 Left-click the mouse. The application opens so you can create the object
youll embed in the report. Since we chose Microsoft Graph, Microsoft
Graph opens.
5 Create the object.
6 Select the applications Update or Return command from the File menu.
ReportSmith places the object where you click in the report. Click to select
the header or footer if the object exceeds its boundaries. Click and drag
one of the four-corner handles until you can see the entire object within
the header or footer boundaries, then release the mouse button.

The object
appearswhere
you drop it

176

Users Guide

Editing an embedded object


To edit an object, double-click on the object itself or on the icon representing
it. In many cases, the object is opened in the application in which it was
created. You can edit the object in a separate window, or the applications
menu, toolbar and ribbon temporarily takes the place of ReportSmiths in the
original window. The latter is called in-place activation. To exit back to
ReportSmith, choose exit from the file menu of the application.
To edit an embedded object:

1 Double-click the object and ReportSmith opens the application so you can
see the object you want to edit, or single-click the object to select it.
2 Select the Object command from the Edit menu.
Note

The application name appears on the Edit menu, along with the Object
command. For example, Edit Microsoft Graph Object appears as the
command name if the object you select was created in Microsoft Graph.
ReportSmith opens the application and displays the selected object you
want to edit.

3 Edit the object.


4 Select the applications Update command from the File menu when you
finish editing and close the application.

Linking objects to a report


To create a link to an object from another application:

1 Create and save the object in its application.


2 Select the object and copy it to the Clipboard with the Copy command on
the Edit menu.
3 Return to the report by minimizing the application or clicking outside the
application window.
Note

Dont close the application from which youre copying the object until youve
selected the Paste Link command. If you close it before, Paste Link command
wont be available on the Edit menu.

1 Select the Paste Link command on the Edit menu.


2 With the mouse, position the Object cursor within the header or footer
where you want to place the object. Click the mouse to place the object in
the report and create a link to the original file in the application. The next
time you open your report, ReportSmith asks if you want to reestablish
the links for the report. If you do, answer yes. ReportSmith updates the
object if there have been changes.
To edit a link:

1 Select Edit|Edit Links to open the Links dialog box.


2 Click the link you want to edit in the Links list box. Choose the Update
option you want to use for the link you selected in the Links list box.

Appendix A, Using ReportSmith with other applications

177

Click Manual if you dont want ReportSmith to automatically update


the object when you open your report.
Click Automatic if you want ReportSmith to automatically update the
object when you open your report.

3 Press the Update Now button if you have Manual set as the Update
option and you want to update the object or if the report the object is in
was open when changes were made to the original file. ReportSmith
updates the object.
To cancel a link:

1 From the Edit menu choose Edit Links. The Links dialog box appears. The
Edit Links command is available only if youve created links. If you
havent, the command is dimmed on the Edit menu.
2 Click the link you want to cancel in the Links list box.
3 Press the Cancel Link button. ReportSmith cancels the link and the Links
options for that link are dimmed.
To change the location of a link:

1 Select the Edit Links command from the Edit menu. The Links dialog box
appears. The Edit Links command is available only if youve created links.
If you havent, the command is dimmed on the Edit menu.
2 Click the link you moved to a new location.
3 Press the Change Link button. The Change Link dialog box appears.
4 Type in the new path for the linked object. ReportSmith changes the link
so it can continue to update the object if any changes are made.

Dragging data between applications


With ReportSmith, you can drag and drop data or objects from one
application to another. However, in order to use this feature your other
application must support OLE Version 2.0.
To copy data from one application to another:

1 Open ReportSmith and display your report.


2 Open the other application and display it on screen along with
ReportSmith. To do this, use the Windows|Tile command.
Note

It is important that both applications be displayed on screen at the same time.

1 Select the object you want to copy.


2 Drag it across into the other application and drop it into place.
ReportSmith copies the object from the first application and copies it into
the second application.
To copy an object to the cursor position in an application:

1 Position the cursor where you want to place the object.


2 In the other application, select the object you want to place.
178

Users Guide

3 Holding the Shift key, drag and drop the object into the receiving
application.
The object appears in the receiving application.
To move an object from one application to another:

1 Select the object you want to move.


2 Holding the Ctrl key, drag the object into the receiving application.
ReportSmith cuts the object, removing it from the first application and
pasting it into the second.

Appendix A, Using ReportSmith with other applications

179

180

Users Guide

Das könnte Ihnen auch gefallen