Creating Excel RTD servers

On this page you will find a step-by-step example of building a Real-Time Data server for Excel XP, 2003, 2007, 2010 and Excel 2013.
The sample project demonstrates how you create an Excel RTD server handling a single topic.

A bit of theory

The RTD Server technology (introduced in Excel 2002) is used to provide the end user with a flow of changing data such as stock quotes,
currency exchange rates etc. If an RTD server is specified in a formula (placed on an Excel worksheet), Excel loads the RTD server and waits
for new data from it. When data arrive, the RTD server notifies Excel. This can be done as many times as required and every time you do this,
Excel simply notes that the RTD server wants to give it an update. When Excel is ready for the update, it asks the RTD server for new data.
Add-in Express allows using this mechanism in two ways:

You can send Excel notifications at the specified time interval (see the ADXRTDServerModule.Interval property); this causes the RefreshData event to occur on every topic component.

You can set ADXRTDServerModule.Interval=0, and call ADXRTDServerModule.UpdateTopic() or ADXRTDServerModule.UpdateTopics() when required.

Excel RTD Server terminology:

An RTD server is a Component Object Model (COM) Automation server that implements the IRtdServer COM interface.
Excel uses the RTD server to communicate with a real-time data source on one or more topics.

A real-time data source is any source of data that you can access programmatically.

A topic is a string (or a set of strings) that uniquely identifies a data source or a piece of data that resides
in a real-time data source. The RTD server retrieves the value corresponding to the topic from the real-time data
source and passes the value to Excel for displaying.

Per-user and per-machine RTD servers

An Excel RTD Server can be registered either for the current user (the user running the installer) or for all users on the machine.
That's why the corresponding module type, ADXRTDServerModule, provides the RegisterForAllUsers property. Registering for
all users means writing to HKLM and that means the user registering a per-machine RTD server must have administrative permissions.
Accordingly, RegisterForAllUsers = Flase means writing to HKCU (=for the current user).

Before you modify the RegisterForAllUsers property, you must unregister the add-in project on your development PC and make sure that adxloader.dll.manifest is writable.

Step 1. Creating an RTD server project

Make sure that you have administrative permissions before running Visual Studio. Run Visual Studio via the Run as Administrator command.

In Visual Studio, open the New Project dialog and navigate to the Extensibility folder.

In the first wizard window, you choose your programming language (C#, VB.NET and C++.NET are supported):

When in the window below, choose Generate new or specify an existing .snk file and click Next. If you do not know anything about strong
names or do not have a special strong name key file, choose Generate new. If you are in doubt, choose Generate new. If, later on, you
need to use a specific strong name key file, you will be able to specify its name on the Signing tab of your project properties; you
are required to unregister your add-in project before using another strong name.

The project wizard creates and opens a new solution in the Visual Studio IDE.

The solution contains an only project, the RTD server project. The project contains the RTDServerModule.vb (or RTDServerModule.cs)
file discussed in the next step.

Step 2. Excel RTD module

RTDServerModule.vb (or RTDServerModule.cs) is the core part of the RTD server project. The module is a container for ADXRTDTopic components.
It is a descendant of the ADXRTDServerModule class implementing the IRtdServer COM interface and allowing you to manage server's
topics and their code.

To review its source code, right-click the file in the Solution Explorer and choose View Code in the context menu.

In the code of the module, pay attention to the CurrentInstace property. It returns the current instance of the RTD module.
This is useful for example, when you need to access a method defined in the module from the code of another class.

Click the designer surface when you need to set properties of your real-time data server in the Properties window.
The RegisterForAllUsers property shown in the screenshot above is described in Per-user and per-machine RTD servers.
The Interval property sets the internal timer that causes Excel to generate the RefreshData event for topics of your RTD server.

Step 4. Adding and handling a new topic

To add a new topic to your RTD server, you use the Add RTD Topic command that places a new ADXRTDTopic component onto the module.
Select the newly added component and, in the Properties window, enter string values identifying the topic in the String## properties.
In this sample, the My Topic string in the String01 property identifies the topic.

It is possible to enter an asterisk (*) in any of the String## properties. When there is no ADXRTDTopic corresponding to the
identifying strings entered by the user, Add-in Express creates a new ADXRTDTopic and passes it to the RefreshData event handler
of the topic containing an asterisk (*). In that event, you can cast the Sender argument to ADXRTDTopic and get actual strings
from its String## properties.

This technology is now available for our custom development services only. Based on the Add-in Express for Office core, it is designed for building custom-tailored Office add-ins with far less coding than you usually have to do. Plus, it includes all Add-in Express features such as True RAD, visual designers, Outlook view and form regions, etc.

Get the best platform for building version-neutral, fast and easy deployable plug-ins by using Add-in Express projects templates, visual designers, components and wizards in combination with a perfect Delphi compiler.

This is an extension for Visual Studio that allows developers to quickly create WiX-based setup projects in a familiar Visual Studio way.

The Designer for WiX Toolset lets you forget the plain Windows Installer XML and concentrate on your deployment logic. It integrates several editors with the Visual Studio IDE and provides a set of vdproj designers to configure the file system, registry, user interface, custom actions, launch conditions and more for your setup projects.

The innovative technology for customizing Outlook views and forms. It is included in all Add-in Express for Office products and can be used to extend Outlook views, e-mail, task and appointment windows, To-Do bar, Reading and Navigation panes with your own custom sub-panes.

Microsoft and the Office logo are trademarks or registered trademarks of Microsoft Corporation in
the United States and/or other countries. All other trademarks are property of their respective owners.