0% found this document useful (0 votes)
2 views77 pages

Matlab Compiler Excel Addin Users Guide Coll download

The document is a user's guide for the MATLAB Compiler Excel Add-In, detailing how to create and distribute Excel add-ins using MATLAB. It covers prerequisites, deployment workflows, and customization options for applications, as well as technical support and contact information for MathWorks. Additionally, it includes links to related MATLAB resources and documentation.

Uploaded by

tjademargis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views77 pages

Matlab Compiler Excel Addin Users Guide Coll download

The document is a user's guide for the MATLAB Compiler Excel Add-In, detailing how to create and distribute Excel add-ins using MATLAB. It covers prerequisites, deployment workflows, and customization options for applications, as well as technical support and contact information for MathWorks. Additionally, it includes links to related MATLAB resources and documentation.

Uploaded by

tjademargis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 77

Matlab Compiler Excel Addin Users Guide Coll

download

https://ebookbell.com/product/matlab-compiler-excel-addin-users-
guide-coll-36653862

Explore and download more ebooks at ebookbell.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

Matlab Compiler Documentation

https://ebookbell.com/product/matlab-compiler-documentation-6741414

Matlab Compiler Sdk Documentation

https://ebookbell.com/product/matlab-compiler-sdk-
documentation-6741904

Matlab Recipes For Earth Sciences 2nd Trauth Martin H

https://ebookbell.com/product/matlab-recipes-for-earth-sciences-2nd-
trauth-martin-h-55923574

Matlab Recipes For Earth Sciences 5th Edition Martin H Trauth

https://ebookbell.com/product/matlab-recipes-for-earth-sciences-5th-
edition-martin-h-trauth-21326300
Matlab Recipes For Earth Sciences 3rd Ed 2010 Martin H Trauth Auth

https://ebookbell.com/product/matlab-recipes-for-earth-sciences-3rd-
ed-2010-martin-h-trauth-auth-2541654

Matlab Essentials A First Course For Engineers And Scientists 1st


Edition Bober

https://ebookbell.com/product/matlab-essentials-a-first-course-for-
engineers-and-scientists-1st-edition-bober-34691002

Matlab And Design Recipes For Earth Sciences How To Collect Process
And Present Geoscientific Information 2013th Edition Martin Trauth

https://ebookbell.com/product/matlab-and-design-recipes-for-earth-
sciences-how-to-collect-process-and-present-geoscientific-
information-2013th-edition-martin-trauth-4144474

Matlab In Bioscience And Biotechnology Leonid Burstein

https://ebookbell.com/product/matlab-in-bioscience-and-biotechnology-
leonid-burstein-4146942

Matlab For Engineers Explained 1st Edition Fredrik Gustafsson

https://ebookbell.com/product/matlab-for-engineers-explained-1st-
edition-fredrik-gustafsson-4189370
MATLAB® Compiler™
MATLAB® Compiler™ Excel® Add-In User's Guide

R2021b
How to Contact MathWorks

Latest news: www.mathworks.com

Sales and services: www.mathworks.com/sales_and_services

User community: www.mathworks.com/matlabcentral

Technical support: www.mathworks.com/support/contact_us

Phone: 508-647-7000

The MathWorks, Inc.


1 Apple Hill Drive
Natick, MA 01760-2098
MATLAB® Compiler™ Excel® Add-In User's Guide
© COPYRIGHT 2015–2021 by The MathWorks, Inc.
The software described in this document is furnished under a license agreement. The software may be used or copied
only under the terms of the license agreement. No part of this manual may be photocopied or reproduced in any form
without prior written consent from The MathWorks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation by, for, or through
the federal government of the United States. By accepting delivery of the Program or Documentation, the government
hereby agrees that this software or documentation qualifies as commercial computer software or commercial computer
software documentation as such terms are used or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014.
Accordingly, the terms and conditions of this Agreement and only those rights specified in this Agreement, shall pertain
to and govern the use, modification, reproduction, release, performance, display, and disclosure of the Program and
Documentation by the federal government (or other entity acquiring for or through the federal government) and shall
supersede any conflicting contractual terms or conditions. If this License fails to meet the government's needs or is
inconsistent in any respect with federal procurement law, the government agrees to return the Program and
Documentation, unused, to The MathWorks, Inc.
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be
trademarks or registered trademarks of their respective holders.
Patents
MathWorks products are protected by one or more U.S. patents. Please see www.mathworks.com/patents for
more information.
Revision History
March 2015 Online only New for Version 6.0 (Release 2015a)
September 2015 Online only Revised for Version 6.1 (Release 2015b)
October 2015 Online only Rereleased for Version 6.0.1 (Release 2015aSP1)
March 2016 Online only Revised for Version 6.2 (Release 2016a)
September 2016 Online Only Revised for Version 6.3 (Release 2016b)
March 2017 Online only Revised for Version 6.4 (Release R2017a)
September 2017 Online only Revised for Version 6.5 (Release R2017b)
March 2018 Online only Revised for Version 6.6 (Release R2018a)
September 2018 Online only Revised for Version 7.0 (Release R2018b)
March 2019 Online only Revised for Version 7.0.1 (Release R2019a)
September 2019 Online only Revised for Version 7.1 (Release R2019b)
March 2020 Online only Revised for Version 8.0 (Release R2020a)
September 2020 Online only Revised for Version 8.1 (Release R2020b)
March 2021 Online only Revised for Version 8.2 (Release R2021a)
September 2021 Online only Revised for Version 8.3 (Release R2021b)
Contents

Create Excel Add-Ins


1
Create Excel Add-In . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2

Getting Started
2
How MATLAB Compiler Excel Integration Works . . . . . . . . . . . . . . . . . . . . 2-2
MATLAB Compiler Excel Add-In Limitations . . . . . . . . . . . . . . . . . . . . . . . 2-2
Next Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2

MATLAB Compiler for Microsoft Excel Add-In Prerequisites . . . . . . . . . . 2-4


Products, Compilers, and IDE Installation . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
Macro Execution Security Levels in Microsoft Excel . . . . . . . . . . . . . . . . . 2-4
Deployment Target Architectures and Compatibility . . . . . . . . . . . . . . . . . 2-4
Dependency and Non-Compilable Code Considerations . . . . . . . . . . . . . . . 2-5
Your Role in the Deployment Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5

Choose Function Deployment Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7


Is Your Function Ready for Deployment? . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7
Other Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7

Create Excel Add-In from MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8


Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
Create Function in MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
Create Excel Add-In Using Library Compiler App . . . . . . . . . . . . . . . . . . . 2-8
Package the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10
Create Excel Add-in Using compiler.build.excelAddIn . . . . . . . . . . . . . . . 2-11
Test the Add-In in Excel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12

Distribute Add-Ins and Integrate Into Microsoft Excel . . . . . . . . . . . . . . 2-14


Integration Process Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-14
Key Tasks for Microsoft Excel End User . . . . . . . . . . . . . . . . . . . . . . . . . 2-14
Files To Distribute To End Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-14
Add-In and COM Component Registration . . . . . . . . . . . . . . . . . . . . . . . . 2-14
Add-In Installation and Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15

iii
Customizing a Compiler Project
3
Customize an Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
Customize the Installer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2
Determine Data Type of Command-Line Input (For Packaging Standalone
Applications Only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
Manage Required Files in Compiler Project . . . . . . . . . . . . . . . . . . . . . . . 3-4
Sample Driver File Creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5
Specify Files to Install with Application . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
Additional Runtime Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7

Manage Support Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9


Using a Compiler App . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
Using the Command Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9

The Function Wizard


4
Execute Functions and Create Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
What Can the Function Wizard Do for Me? . . . . . . . . . . . . . . . . . . . . . . . . 4-3
Installation of the Function Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
Function Wizard Start-Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
Workflow Selection for MATLAB Functions Ready for Deployment . . . . . . 4-5
Defining Functions Ready to Execute . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-5
Function Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13
Macro Creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13
Macro Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13
Microsoft Visual Basic Code Access (Optional Advanced Task) . . . . . . . . 4-14
For More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-15

End-to-End Deployment of MATLAB Function . . . . . . . . . . . . . . . . . . . . . 4-16


What Can the Function Wizard Do for Me? . . . . . . . . . . . . . . . . . . . . . . . 4-17
Example File Copying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-18
mymagic Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-18
Installation of the Function Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-19
Function Wizard Start-Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20
Workflow Selection for Prototyping and Debugging MATLAB Functions . 4-21
New MATLAB Function Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-23
MATLAB Function Prototyping and Debugging . . . . . . . . . . . . . . . . . . . . 4-32
Function Execution from MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-32
Microsoft Excel Add-In and Macro Creation Using the Function Wizard . 4-33
Function Execution from the Deployed Component . . . . . . . . . . . . . . . . . 4-34
Macro Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-35
Microsoft Excel Add-In and Macro Packaging using the Function Wizard
..................................................... 4-35
Microsoft Visual Basic Code Access (Optional Advanced Task) . . . . . . . . 4-36
For More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-37

iv Contents
MATLAB Code Deployment
5
How Does MATLAB Deploy Functions? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2

Dependency Analysis Using MATLAB Compiler . . . . . . . . . . . . . . . . . . . . . 5-3


Function Dependency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
Data File Dependency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
Exclude Files From Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4

MEX-Files, DLLs, or Shared Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-5

Deployable Archive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6


Additional Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-7

Write Deployable MATLAB Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-9


Packaged Applications Do Not Process MATLAB Files at Run Time . . . . . . 5-9
Do Not Rely on Changing Directory or Path to Control the Execution of
MATLAB Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-10
Use isdeployed Functions To Execute Deployment-Specific Code Paths . . 5-10
Gradually Refactor Applications That Depend on Noncompilable Functions
..................................................... 5-10
Do Not Create or Use Nonconstant Static State Variables . . . . . . . . . . . . 5-10
Get Proper Licenses for Toolbox Functionality You Want to Deploy . . . . . 5-11

Calling Shared Libraries in Deployed Applications . . . . . . . . . . . . . . . . . 5-12

MATLAB Data Files in Compiled Applications . . . . . . . . . . . . . . . . . . . . . 5-13


Explicitly Including MATLAB Data files Using the %#function Pragma . . 5-13
Load and Save Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-13

Microsoft Excel Add-In Creation, Function Execution, and


Deployment
6
The Library Compiler and the Command Line Interface . . . . . . . . . . . . . . 6-2
Using Graphical Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
Using Command Line Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2

Create Macros from MATLAB Functions with Multiple Arguments . . . . . 6-3


Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3
Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3
Inspect the Microsoft Visual Basic Code (Optional) . . . . . . . . . . . . . . . . . . 6-7

Execute Add-In and Graphical Function . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-8


Execute an Add-In to Validate Nongraphical Function Output . . . . . . . . . . 6-8
Execute a Graphical Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-8
Create Dialog Box and Error Message Macros . . . . . . . . . . . . . . . . . . . . 6-10

v
Microsoft Excel Add-In Integration
7
Integrate Components Using Visual Basic Application . . . . . . . . . . . . . . . 7-2
When to Use Formula Functions or Subroutines . . . . . . . . . . . . . . . . . . . . 7-2
Initialize MATLAB Compiler Libraries with Microsoft Excel . . . . . . . . . . . . 7-2
Create an Instance of a Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3
Call the Methods of a Class Instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4
Program with Variable Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-6
Modify Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7
Handle Errors During a Method Call . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-10

Build and Integrate Spectral Analysis Functions . . . . . . . . . . . . . . . . . . . 7-11


Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11
Build Excel Add-In . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11
Implement VBA code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-12
Test the Add-In . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-18

For More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-21

Distribution to End Users


8
Assign Multiple MATLAB Functions to Excel Class . . . . . . . . . . . . . . . . . . 8-2
Create Add-In In MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
Deploy Add-In to Microsoft Excel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2

Improve Data Access Using the MATLAB Runtime User Data Interface
and COM Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4

MATLAB Runtime Component Cache and Deployable Archive Embedding


.......................................................... 8-8
Overriding Default Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-9
For More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-9

MATLAB Runtime Options for Excel Add-Ins . . . . . . . . . . . . . . . . . . . . . . 8-10


What MATLAB Runtime Options are Supported by MATLAB Compiler? . . 8-10
How Do I Specify MATLAB Runtime Options? . . . . . . . . . . . . . . . . . . . . . 8-10

For More Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-11

vi Contents
Functions
9

Utility Library for Microsoft COM Components


10
Reference Utility Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-2

Class MWUtil . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-3


Sub MWInitApplication(pApp As Object) . . . . . . . . . . . . . . . . . . . . . . . . . 10-3
Sub MWInitApplicationWithMCROptions(pApp As Object, [mcrOptionList])
..................................................... 10-4
Function IsMCRJVMEnabled() As Boolean . . . . . . . . . . . . . . . . . . . . . . . 10-5
Function IsMCRInitialized() As Boolean . . . . . . . . . . . . . . . . . . . . . . . . . 10-5
Sub MWPack(pVarArg, [Var0], [Var1], ... ,[Var31]) . . . . . . . . . . . . . . . . . . 10-5
Sub MWUnpack(VarArg, [nStartAt As Long], [bAutoResize As Boolean =
False], [pVar0], [pVar1], ..., [pVar31]) . . . . . . . . . . . . . . . . . . . . . . . . . 10-7
Sub MWDate2VariantDate(pVar) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-8

Class MWFlags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-10


Property ArrayFormatFlags As MWArrayFormatFlags . . . . . . . . . . . . . . 10-10
Property DataConversionFlags As MWDataConversionFlags . . . . . . . . . 10-12
Sub Clone(ppFlags As MWFlags) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-13

Class MWStruct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-15


Sub Initialize([varDims], [varFieldNames]) . . . . . . . . . . . . . . . . . . . . . . 10-15
Property Item([i0], [i1], ..., [i31]) As MWField . . . . . . . . . . . . . . . . . . . . 10-16
Property NumberOfFields As Long . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-17
Property NumberOfDims As Long . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-18
Property Dims As Variant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-18
Property FieldNames As Variant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-18
Sub Clone(ppStruct As MWStruct) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-18

Class MWField . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-20


Property Name As String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-20
Property Value As Variant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-20
Property MWFlags As MWFlags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-20
Sub Clone(ppField As MWField) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-20

Class MWComplex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-21


Property Real As Variant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-21
Property Imag As Variant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-21
Property MWFlags As MWFlags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-21
Sub Clone(ppComplex As MWComplex) . . . . . . . . . . . . . . . . . . . . . . . . 10-22

Class MWSparse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-23


Property NumRows As Long . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-23
Property NumColumns As Long . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-23
Property RowIndex As Variant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-23
Property ColumnIndex As Variant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-23
Property Array As Variant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-23

vii
Property MWFlags As MWFlags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-23
Sub Clone(ppSparse As MWSparse) . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-23

Class MWArg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-26


Property Value As Variant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-26
Property MWFlags As MWFlags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-26
Sub Clone(ppArg As MWArg) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-26

Enum mwArrayFormat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-27

Enum mwDataType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-28

Enum mwDateFormat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-29

Apps
11

Data Conversion
A
Data Conversion Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-2

Array Formatting Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-10

Data Conversion Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-12


CoerceNumericToType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-12
InputDateFormat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-13
OutputAsDate As Boolean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-13
DateBias As Long . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-13

Troubleshooting
B
Errors and Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-2
Excel Add-Ins Errors and Suggested Solutions . . . . . . . . . . . . . . . . . . . . . B-3
Required Locations to Develop and Use Components . . . . . . . . . . . . . . . . B-5
Microsoft Excel Errors and Suggested Solutions . . . . . . . . . . . . . . . . . . . B-5
Function Wizard Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-6

Deployment Product Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-8

viii Contents
1

Create Excel Add-Ins


1 Create Excel Add-Ins

Create Excel Add-In


1 Type libraryCompiler at the MATLAB command line to open the Library Compiler app.
2 In the Library Compiler app project window, specify the files of the MATLAB application that
you want to deploy.

a
In the Exported Functions section of the toolstrip, click .
b In the Add Files window, browse to the example folder, and select the function you want to
package. Click Open.

The function is added to the list of exported function files. Repeat this step to package multiple
files in the same application.
3 In the Packaging Options section of the toolstrip, decide whether to include the MATLAB
Runtime installer in the generated application by selecting one of the options:

• Runtime downloaded from web — Generate an installer that downloads the MATLAB
Runtime and installs it along with the deployed MATLAB application. You can specify the file
name of the installer.
• Runtime included in package — Generate an application that includes the MATLAB
Runtime installer. You can specify the file name of the installer.

Note The first time you select this option, you are prompted to download the MATLAB
Runtime installer.
4 Verify that the MATLAB function you are packing into an Excel add-in is mapped onto a class. You
can change the name from the default name Class 1 to something more meaningful.
5 Customize the packaged application and its appearance:

• Library information — Editable information about the deployed application. You can also
customize the standalone applications appearance by changing the application icon and
splash screen. The generated installer uses this information to populate the installed
application metadata. See “Customize the Installer”.
• Additional installer options — Edit the default installation path for the generated installer
and selecting custom logo. See “Change the Installation Path” .
• Files required for your library to run — Additional files required by the generated
application to run. These files are included in the generated application installer. See
“Manage Required Files in Compiler Project”.
• Files installed for your end user — Files that are installed with your application.

See “Specify Files to Install with Application”.


• Additional runtime settings — Platform-specific options for controlling the generated
executable. See “Additional Runtime Settings”.
6 When you are finished selecting your packaging options, save your Library Compiler project
and generate the packaged application.

1 Click Package.

In the Save Project dialog box, specify the location to save the project.
2 In the Package dialog box, verify that Open output folder when process completes is
selected.

1-2
Create Excel Add-In

When the packaging process is complete, examine the generated output in the target folder.

• Three folders are generated: for_redistribution,


for_redistribution_files_only, and for_testing.

For more information about the files generated in these folders, see “Files Generated
After Packaging MATLAB Functions”.
• The log file PackagingLog.html contains packaging results.

See Also

More About
• “Create Excel Add-In from MATLAB” on page 2-8

1-3
2

Getting Started

• “How MATLAB Compiler Excel Integration Works” on page 2-2


• “MATLAB Compiler for Microsoft Excel Add-In Prerequisites” on page 2-4
• “Choose Function Deployment Workflow” on page 2-7
• “Create Excel Add-In from MATLAB” on page 2-8
• “Distribute Add-Ins and Integrate Into Microsoft Excel” on page 2-14
2 Getting Started

How MATLAB Compiler Excel Integration Works


With MATLAB Compiler, you create deployable add-ins from MATLAB code that run in Microsoft®
Excel applications. Use the Library Compiler app, compiler.build.excelAddIn, or mcc to
convert MATLAB functions to methods of a class that you define. From this class, the compiler
creates the Excel add-in.

MATLAB Compiler generates two primary artifacts from your MATLAB code: a COM component
(.dll file) and a Visual Basic® for Applications (VBA) module file (.bas file). The compiler integrates
the COM wrapper with the compiler-generated VBA code to create a Microsoft Excel add-in (.xla
file), saving you considerable development resources and time.

COM is an acronym for Component Object Model, which is a Microsoft binary standard for object
interoperability. COM components use a common integration architecture that provides a consistent
model across multiple applications. All Microsoft Office applications support COM add-ins.

Each COM object exposes a class to the Visual Basic programming environment. The class contains a
set of functions called methods. These methods correspond to the original MATLAB functions
included in the project. MATLAB Compiler generated COM components contain a single class. This
class provides the interface to the MATLAB functions that you add to the class at build time. The
COM component provides a set of methods that wrap the MATLAB code and a DLL file.

The MATLAB Compiler generates supporting files. Include these supporting files when you package
and distribute an application. Include MATLAB Runtime to access an entire library of MATLAB
functions without needing a licensed copy of MATLAB.

For information about how MATLAB Compiler works, see “How Does MATLAB Deploy Functions?” on
page 5-2.

To verify your MATLAB code or function can be deployed successfully, see “Write Deployable MATLAB
Code”.

MATLAB Compiler Excel Add-In Limitations


Generated add-ins support the following function outputs:

• No outputs
• Figure (graphical) output
• Scalar output
• Multidimensional matrix output

MATLAB objects are not supported as inputs or outputs for compiled or deployed functions with
MATLAB Compiler for Excel add-ins.

Next Steps
MATLAB Compiler includes several examples in addition to the magic square example. You can find
these examples in matlabroot\toolbox\matlabxl\examples\. The following table identifies
examples by folder:

2-2
How MATLAB Compiler Excel Integration Works

For Example Files Relating Find Example Code in For Example Documentation
To... Folder... See...
Magic Square Example xlmagic “Create Excel Add-In from
MATLAB” on page 2-8
Variable-Length Argument xlmulti “Create Macros from MATLAB
Example Functions with Multiple
Arguments” on page 6-3
Calling Compiled MATLAB xlbasic “Assign Multiple MATLAB
Functions from Microsoft Excel Functions to Excel Class” on
page 8-2
Spectral Analysis Example xlspectral “Build and Integrate Spectral
Analysis Functions” on page 7-
11

The following topics detail some of the more common tasks you perform as you continue to develop
your applications.

To: See:
Try more examples using the MATLAB Compiler MATLAB Central. Set the Search field to File
Exchange and search for one or more of the
following:

• InterpExcelDemo
• MatrixMathExcelDemo
• ExcelCurveFit
Learn how to write MATLAB code that is “Write Deployable MATLAB Code”
optimized for deployment
Work with functions having graphical output “Execute Add-In and Graphical Function” on page
6-8
Work with functions having variable inputs and “Create Macros from MATLAB Functions with
output Multiple Arguments” on page 6-3
Create displayable dialog boxes and error “Create Dialog Box and Error Message Macros”
messages on page 6-10
Troubleshoot common error messages “Errors and Solutions” on page B-2
Integrate your application into your enterprise “Integrate Components Using Visual Basic
environment by enhancing your application's Application” on page 7-2
generated Visual Basic code

See Also

Related Examples
• “Distribute Add-Ins and Integrate Into Microsoft Excel” on page 2-14
• “How Does MATLAB Deploy Functions?” on page 5-2
• “Write Deployable MATLAB Code”

2-3
2 Getting Started

MATLAB Compiler for Microsoft Excel Add-In Prerequisites


In this section...
“Products, Compilers, and IDE Installation” on page 2-4
“Macro Execution Security Levels in Microsoft Excel” on page 2-4
“Deployment Target Architectures and Compatibility” on page 2-4
“Dependency and Non-Compilable Code Considerations” on page 2-5
“Your Role in the Deployment Process” on page 2-5

Products, Compilers, and IDE Installation


To generate Microsoft Excel add-ins using MATLAB, you must have the following installed:

• MATLAB
• MATLAB Compiler
• A supported C or C++ compiler

Macro Execution Security Levels in Microsoft Excel


To create macros and generate add-ins with MATLAB Compiler, you must adjust the security settings
accordingly in Microsoft Excel.

Failure to do so may result in add-ins not being generated or warning messages sent to MATLAB
Compiler

Depending on what version of Microsoft Excel you are using, do one of the following:

• For Microsoft Excel 2010 or newer:

1 Click File > Options > Trust Center > Trust Center Settings > Macro Settings.
2 In Developer Macro Settings, select Trust access to the VBA project object model.
• For Microsoft Excel 2007:

1 Click the 2007 Excel ribbon button.


2 Click Excel Options > Trust Center > Trust Center Settings > Macro Settings.
3 In Developer Macro Settings, select Trust access to the VBA project object model.
• For Microsoft Excel 2003:

1 Click
Tools > Macro > Security.
2 For Security Level, select Medium.

Deployment Target Architectures and Compatibility


Before you deploy a component with MATLAB Compiler, consider if your target machines are 32-bit
or 64-bit.

2-4
MATLAB Compiler for Microsoft Excel Add-In Prerequisites

Applications developed on one architecture must be compatible with the architecture on the system
where they are deployed. For example, if you have a 64-bit system, you usually install a 64-bit version
of MATLAB (and most other applications) by default. Running functions you have developed with a
64-bit version of MATLAB requires a 64-bit version of Microsoft Excel.

Migration Considerations for 32-bit and 64-bit Microsoft Excel

Add-ins created with MATLAB Compiler are compatible with both 32–bit and 64–bit versions of
Microsoft Excel. MATLAB Compiler itself is in 64–bit only.

Dependency and Non-Compilable Code Considerations


Before you deploy your code, examine the code for dependencies on functions that may not be
compatible with MATLAB Compiler.

For more detailed information about dependency analysis (depfun) and how MATLAB Compiler
evaluates MATLAB code prior to compilation, see “Write Deployable MATLAB Code”.

Your Role in the Deployment Process


The table below describes the different roles, or jobs, that MATLAB Compiler users typically perform.
It also describes tasks they would most likely perform when running the examples in this
documentation. You may occupy one or more of the following roles.

2-5
2 Getting Started

Application Deployment Roles, Goals, and Tasks

Role Knowledge Base Responsibilities


MATLAB programmer • Understand the end-user • Build a Microsoft Excel add-
business requirements and in with MATLAB tools.
the mathematical models • Package the component for
that support them. distribution to customers.
• MATLAB expert • Pass the package to the
• No IT experience Microsoft Excel developer
for further integration into
the end-user environment.

.
Microsoft Excel developer • Some or no MATLAB • Roll out the packaged
experience. component and integrate it
• Microsoft Excel expert. into the end-user
environment.
• Proficient writing VB/VBA
code. • Write VB/VBA code to
complement or augment the
Excel add-in built by the
MATLAB programmer. Add
and modify code as needed.
• Uses Function Wizard to
customize the add-in and
create executable macros.
• Verify that the final
application executes reliably
in the end-user environment.

2-6
Choose Function Deployment Workflow

Choose Function Deployment Workflow


In this section...
“Is Your Function Ready for Deployment?” on page 2-7
“Other Examples” on page 2-7

Is Your Function Ready for Deployment?


If These Statements are True... See...
• I have a MATLAB function that conforms See “Create Excel Add-In from MATLAB” on page 2-
to guidelines in “Write Deployable 8 to build your add-in
MATLAB Code”. and
• I want to create a Microsoft Excel “Distribute Add-Ins and Integrate Into Microsoft
compatible add-in from my existing Excel” on page 2-14 to execute the newly built add-
MATLAB function. in and create macros and associated GUIs with the
Function Wizard and Microsoft Excel.
• I have tested and debugged my MATLAB
function with MATLAB.
• I have not yet developed a MATLAB See “End-to-End Deployment of MATLAB Function”
function for deployment as an add-in, or I on page 4-16 for an end-to-end example of creating,
am in the process of developing it. debugging, building, and packaging MATLAB function
• I have not tested my MATLAB function from scratch using the Function Wizard.
thoroughly with MATLAB.

Other Examples
For other types of examples, see the following:

• “Execute Add-In and Graphical Function” on page 6-8


• “Create Macros from MATLAB Functions with Multiple Arguments” on page 6-3
• MATLAB Central. Set the Search field to File Exchange and search for one or more of the
following:

• InterpExcelDemo
• MatrixMathExcelDemo
• ExcelCurveFit

2-7
2 Getting Started

Create Excel Add-In from MATLAB


Supported Platform: Windows® only.

This example shows how to use MATLAB Compiler to generate a Microsoft Excel add-in containing a
custom function for use within Excel. The custom function mymagic returns an n-by-n matrix filled
with positive integers with equal row and column sums. The target system does not require a licensed
copy of MATLAB to run the add-in.

Prerequisites
• Verify that you have met all of the MATLAB Compiler Excel target requirements. For details, see
“MATLAB Compiler for Microsoft Excel Add-In Prerequisites” on page 2-4.
• Verify that you have Microsoft Excel installed.
• End users must have an installation of MATLAB Runtime to run the add-in. For details, see “Install
and Configure MATLAB Runtime” (MATLAB Compiler SDK).

For testing purposes, you can use an installation of MATLAB instead of MATLAB Runtime.

Create Function in MATLAB


In MATLAB, locate the MATLAB code that you want to deploy as an Excel add-in.

For this example, compile using the file mymagic.m located in matlabroot\toolbox\matlabxl
\examples\xlmagic.

function y = mymagic(x)
y = magic(x)

At the MATLAB command prompt, enter mymagic(5).

The output is a 5-by-5 square.

17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9

Create Excel Add-In Using Library Compiler App


Package the function into an Excel add-in using the Library Compiler app. Alternatively, if you want
to create an Excel add-in from the MATLAB command window using a programmatic approach, see
“Create Excel Add-in Using compiler.build.excelAddIn” on page 2-11.

1 On the MATLAB Apps tab, on the far right of the Apps section, click the arrow. In Application
Deployment, click Library Compiler. In the MATLAB Compiler project window, click Excel
Add-in.

2-8
Create Excel Add-In from MATLAB

Alternately, you can open the Library Compiler app by entering libraryCompiler at the
MATLAB prompt.
2 In the Library Compiler app project window, specify the files of the MATLAB application that
you want to deploy.

a
In the Exported Functions section of the toolstrip, click .
b In the Add Files window, browse to the example folder, and select the function you want to
package. Click Open.

The function is added to the list of exported function files. Repeat this step to package multiple
files in the same application.
3 In the Packaging Options section of the toolstrip, decide whether to include the MATLAB
Runtime installer in the generated application by selecting one of the options:

• Runtime downloaded from web — Generate an installer that downloads the MATLAB
Runtime and installs it along with the deployed MATLAB application. You can specify the file
name of the installer.
• Runtime included in package — Generate an application that includes the MATLAB
Runtime installer. You can specify the file name of the installer.

Note The first time you select this option, you are prompted to download the MATLAB
Runtime installer.
4 Verify that the function defined in mymagic.m is mapped into Class1.

5 Customize the packaged application and its appearance:

• Library information — Editable information about the deployed application. The generated
installer uses this information to populate the installed application metadata. See “Customize
the Installer”.
• Additional installer options — Edit the default installation path for the generated installer
and selecting custom logo. See “Change the Installation Path” .
• Files required for your library to run — Additional files required by the generated
application to run. These files are included in the generated application installer. See
“Manage Required Files in Compiler Project”.

2-9
2 Getting Started

• Files installed for your end user — Files that are installed with your application.

See “Specify Files to Install with Application”.


• Additional runtime settings — Platform-specific options for controlling the generated
executable. See “Additional Runtime Settings”.

Package the Application


When you are finished selecting your packaging options, save your Library Compiler project and
generate the packaged application.

1 Click Package.

In the Save Project dialog box, specify the location to save the project.
2 In the Package dialog box, verify that Open output folder when process completes is
selected.

When the packaging process is complete, examine the generated output in the target folder.

• Three folders are generated: for_redistribution, for_redistribution_files_only,


and for_testing.

2-10
Create Excel Add-In from MATLAB

For more information about the files generated in these folders, see “Files Generated After
Packaging MATLAB Functions”.
• The log file PackagingLog.html contains packaging results.

Create Excel Add-in Using compiler.build.excelAddIn


As an alternative to the Library Compiler app, you can create an Excel add-in using a programmatic
approach. If you have already created an add-in using the Library Compiler, see “Test the Add-In in
Excel” on page 2-12.

1 In MATLAB, locate the MATLAB code that you want to deploy as a standalone application. For
this example, compile using the file mymagic.m located in matlabroot\toolbox\matlabxl
\examples\xlmagic.
appFile = fullfile(matlabroot,'toolbox','matlabxl','examples','xlmagic','mymagic.m');
2 Build the Excel add-in using the compiler.build.excelAddIn function. Use name-value
arguments to generate the BAS and XLA files.

Note To generate the XLA file, enable Trust access to the VBA project object model in Excel.

buildResults = compiler.build.excelAddIn(appFile, ...


'GenerateVisualBasicFile','on')

The compiler.build.Results object buildResults contains information on the build type,


generated files, included support packages, and build options.

The function generates the following files within a folder named mymagicexcelAddIn in your
current working directory:

• dlldata.c
• GettingStarted.html
• includedSupportPackages.txt
• mymagic.def
• mymagic.bas
• mymagic.rc
• mymagic.xla
• mymagic_1_0.dll
• mymagic_dll.cpp
• mymagic_idl.h
• mymagic_idl.idl
• mymagic_idl.tlb
• mymagic_idl_i.c
• mymagic_idl_p.c
• mymagicClass_com.cpp
• mymagicClass_com.hpp
• mccExcludedFiles.log

2-11
2 Getting Started

• mwcomtypes.h
• mwcomtypes_i.c
• mwcomtypes_p.c
• readme.txt
• requiredMCRProducts.txt
• unresolvedSymbols.txt

Note The generated assembly does not include MATLAB Runtime or an installer. To create an
installer using the buildResults object, see compiler.package.installer.

Specify additional options by using one or more comma-separated pairs of name-value arguments
in the compiler.build command.

• 'AddInName' — Name of the generated add-in.


• 'AddInVersion' — System level version of the generated add-in.
• 'AdditionalFiles' — Paths to additional files to include in the add-in.
• 'AutoDetectDataFiles' — Flag to automatically include data files.
• 'ClassName' — Name of the class.
• 'DebugBuild' — Flag to enable debug symbols..
• 'EmbedArchive' — Flag to embed the deployable archive in the generated add-in.
• 'GenerateVisualBasicFile' — Flag to generate a Visual Basic file (.bas) and an Excel
add-in file (.xla).
• 'OutputDirectory' — Path to the output directory that contains generated files.
• 'SupportPackages' — Method to include support packages.
• 'Verbose' — Flag to display progress information indicating compiler output during the
build process.

For example, you can specify the add-in name and enable verbose output.
buildResults = compiler.build.excelAddIn(appFile,...
'GenerateVisualBasicFile','on', ...
'AddInName','MyMagicExcel','Verbose','On');

Test the Add-In in Excel


Add the Add-In to Excel

1 Open Microsoft Excel.


2 Click the File tab, click Options, and then click the Add-Ins category.
3 In the Manage box, click Excel Add-ins, and then click Go. The Add-Ins dialog box appears.
4 Click Browse and locate the add-in mymagic.xla.
5 You are prompted to copy mymagic.xla to the Addins folder associated with your user name.
You can choose to copy the add-in or run it directly. For this example, select, YES. The add-in is
copied and added to your workbook.
6 Click OK to close the Add-Ins dialog box

2-12
Create Excel Add-In from MATLAB

Test the Add-In

1 Select a grid of 3-by-3 cells in the Excel workbook.


2 Enter the following custom function in the formula bar:

=mymagic(3)

As you type my in the formula bar, mymagic appears as a custom function in Excel.
3 Press Ctrl+Shift+Enter on the keyboard.

The selected cells display the following output:

8 1 6
3 5 7
4 9 2

Distribute Add-In

To distribute your add-in to end users, see “Distribute Add-Ins and Integrate Into Microsoft Excel” on
page 2-14.

See Also
libraryCompiler | compiler.build.excelAddIn

More About
• “Execute Functions and Create Macros” on page 4-2

2-13
2 Getting Started

Distribute Add-Ins and Integrate Into Microsoft Excel

Integration Process Overview


Each MATLAB Compiler component is built as a COM object that you can access from Microsoft Excel
through Microsoft Visual Basic for Applications (VBA). You can integrate the MATLAB Compiler
components into Excel using the VBA programming environment.

For general information on programming in Visual Basic, refer to the VBA documentation provided
with Excel.

Key Tasks for Microsoft Excel End User


Task Reference
Verify that you have received all necessary files “Files To Distribute To End Users” on page 2-14
from the MATLAB programmer.
Verify registry permissions for the add-in file and “Add-In and COM Component Registration” on
associated DLL component. page 2-14
Execute your generated functions and create “Execute Functions and Create Macros” on page
macros. 4-2
Install MATLAB Runtime on target systems and “Install and Configure MATLAB Runtime”
update system paths.
Use the Excel add-in. “Add-In Installation and Distribution” on page 2-
15

Files To Distribute To End Users


After you create your Excel add-in, distribute the generated installer to your end user. The installer
installs the packaged add-in and MATLAB Runtime.

If you do not create an installer, distribute the files that the Library Compiler generates in the
for_redistribution_files_only folder. For a list of files generated in each folder, see “Files
Generated After Packaging MATLAB Functions”.

Add-In and COM Component Registration


When you create your COM component, it is registered in either HKEY_LOCAL_MACHINE or
HKEY_CURRENT_USER, based on your log-in privileges.

If you find you need to change your run-time permissions due to security standards imposed by
Microsoft or your installation, you can do one of the following before deploying your COM component
or add-in:

• Log on as administrator before running your COM component or add-in


• Run the following mwregsvr command prior to running your COM component or add-in, as
follows:

mwregsvr [/u] [/s] [/useronly] project_name.dll

2-14
Distribute Add-Ins and Integrate Into Microsoft Excel

where:

• /u allows any user to unregister a COM component or add-in for this server
• /s runs this command silently, generating no messages. This is helpful for use in silent
installations.
• /useronly allows only the currently logged-in user to run the COM component or add-in on
this server

Caution If your COM component is registered in the USER hive, it will not be visible to Windows
Vista™ or Windows 7 users running as administrator on systems with UAC (User Access
Control) enabled.

If you register a component to the USER hive under Windows 7 or Windows Vista, your COM
component may fail to load when running with elevated (administrator) privileges.

If this occurs, do the following to re-register the component to the LOCAL MACHINE hive:

1 Unregister the component with this command:

mwregsvr /u /useronly my_dll.dll


2 Reregister the component to the LOCAL MACHINE hive with this command:

mwregsvr my_dll.dll

Add-In Installation and Distribution


Since Microsoft Excel add-ins are written directly to the distrib folder by MATLAB Compiler, you
and your end users install them exactly as you install the Function Wizard in “Installation of the
Function Wizard” on page 4-3.

Call Add-In Code from Excel Spreadsheet

To run the executable code from a cell in the Excel spreadsheet, invoke the add-in name with a
method call. For example, if you deployed a piece of MATLAB code called mymagic.m, or a figure
called mymagic.fig, you invoke that code by entering the following in a cell in the spreadsheet:

=mymagic()

Tip If the method call does not evaluate immediately, press Ctrl, Shift, and Enter simultaneously.

See Also

Related Examples
• “How MATLAB Compiler Excel Integration Works” on page 2-2
• “Integrate Components Using Visual Basic Application” on page 7-2
• “Reference Utility Classes” on page 10-2
• “Errors and Solutions” on page B-2

2-15
3

Customizing a Compiler Project

• “Customize an Application” on page 3-2


• “Manage Support Packages” on page 3-9
3 Customizing a Compiler Project

Customize an Application
You can customize an application in several ways: customize the installer, manage files in the project,
or add a custom installer path using the Application Compiler app or the Library Compiler app.

Customize the Installer


Change Application Icon

To change the default icon, click the graphic to the left of the Library name or Application name
field to preview the icon.

Click Select icon, and locate the graphic file to use as the application icon. Select the Use mask
option to fill any blank spaces around the icon with white or the Use border option to add a border
around the icon.

To return to the main window, click Save and Use.

Add Library or Application Information

You can provide further information about your application as follows:

• Library/Application Name: The name of the installed MATLAB artifacts. For example, if the name
is foo, the installed executable is foo.exe, and the Windows start menu entry is foo. The folder
created for the application is InstallRoot/foo.

The default value is the name of the first function listed in the Main File(s) field of the app.
• Version: The default value is 1.0.
• Author name: Name of the developer.
• Support email address: Email address to use for contact information.
• Company name: The full installation path for the installed MATLAB artifacts. For example, if the
company name is bar, the full installation path would be InstallRoot/bar/ApplicationName.
• Summary: Brief summary describing the application.
• Description: Detailed explanation about the application.

All information is optional and, unless otherwise stated, is only displayed on the first page of the
installer. On Windows systems, this information is also displayed in the Windows Add/Remove
Programs control panel.

3-2
Customize an Application

Change the Splash Screen

The installer splash screen displays after the installer has started. It is displayed along with a status
bar while the installer initializes.

You can change the default image by clicking the Select custom splash screen. When the file
explorer opens, locate and select a new image.

You can drag and drop a custom image onto the default splash screen.

Change the Installation Path

This table lists the default path the installer uses when installing the packaged binaries onto a target
system.

Windows C:\Program Files\companyName\appName


Mac OS X /Applications/companyName/appName
®
Linux /usr/companyName/appName

You can change the default installation path by editing the Default installation folder field under
Additional installer options.

3-3
3 Customizing a Compiler Project

A text field specifying the path appended to the root folder is your installation folder. You can pick the
root folder for the application installation folder. This table lists the optional custom root folders for
each platform:

Windows C:\Users\userName\AppData
Linux /usr/local

Change the Logo

The logo displays after the installer has started. It is displayed on the right side of the installer.

You change the default image in Additional Installer Options by clicking Select custom logo.
When the file explorer opens, locate and select a new image. You can drag and drop a custom image
onto the default logo.

Edit the Installation Notes

Installation notes are displayed once the installer has successfully installed the packaged files on the
target system. You can provide useful information concerning any additional setup that is required to
use the installed binaries and instructions for how to run the application.

Determine Data Type of Command-Line Input (For Packaging


Standalone Applications Only)
When an executable standalone application is run in the command prompt, the default input type is
char. You can keep this default, or choose to interpret all inputs as numeric MATLAB doubles.

To pass inputs to the standalone application as MATLAB character vectors, select Treat all inputs to
the app as MATLAB character vectors. In this case, you must include code to convert char to a
numeric MATLAB type in the MATLAB function to be deployed as a standalone application.

To pass inputs to the standalone application as numeric MATLAB variables, select Treat all inputs to
the app as numeric MATLAB doubles. option in the Application Compiler App. Thus, you do not
need to include code to convert char to a numeric MATLAB type. Non numeric inputs to the
application may result in an error.

Manage Required Files in Compiler Project


The compiler uses a dependency analysis function to automatically determine what additional
MATLAB files are required for the application to package and run. These files are automatically
packaged into the generated binary. The compiler does not generate any wrapper code that allows
direct access to the functions defined by the required files.

3-4
Customize an Application

If you are using one of the compiler apps, the required files discovered by the dependency analysis
function are listed in the Files required for your application to run or Files required for your
library to run field.

To add files, click the plus button in the field, and select the file from the file explorer. To remove files,
select the files, and press the Delete key.

Caution Removing files from the list of required files may cause your application to not package or
not to run properly when deployed.

Using mcc

If you are using mcc to package your MATLAB code, the compiler does not display a list of required
files before running. Instead, it packages all the required files that are discovered by the dependency
analysis function and adds them to the generated binary file.

You can add files to the list by passing one or more -a arguments to mcc. The -a arguments add the
specified files to the list of files to be added into the generated binary. For example, -a hello.m
adds the file hello.m to the list of required files and -a ./foo adds all the files in foo and its
subfolders to the list of required files.

Sample Driver File Creation


The following target types support sample driver file creation in MATLAB Compiler SDK™:

• C++ shared library


• Java® package
• .NET assembly
• Python® package

The sample driver file creation feature in Library Compiler uses MATLAB code to generate sample
driver files in the target language. The sample driver files are used to implement the generated
shared libraries into an application in the target language. In the app, click Create New Sample to
automatically generate a new MATLAB script, or click Add Existing Sample to upload a MATLAB
script that you have already written. After you package your functions, a sample driver file in the
target language is generated from your MATLAB script and is saved in
for_redistribution_files_only\samples. Sample driver files are also included in the installer
in for_redistribution.

3-5
3 Customizing a Compiler Project

To automatically generate a new MATLAB file, click Create New Sample. This opens up a MATLAB
file for you to edit. The sample file serves as a starting point, and you can edit it as necessary based
on the behavior of your exported functions. The sample MATLAB files must follow these guidelines:

• The sample file code must use only exported functions.


• Each exported function must be in a separate sample file.
• Each call to the same exported function must be a separate sample file.
• The output of the exported function must be an n-dimensional numeric, char, logical, struct, or cell
array.
• Data must be saved as a local variable and then passed to the exported function in the sample file
code.
• Sample file code should not require user interaction.

Additional considerations specific to the target language are as follows:

• C++ mwArray API — varargin and varargout are not supported.


• .NET — Type-safe API is not supported.
• Python — Cell arrays and char arrays must be of size 1xN and struct arrays must be scalar. There
are no restrictions on numeric or logical arrays, other than that they must be rectangular, as in
MATLAB.

To upload a MATLAB file that you have already written, click Add Existing Sample. The MATLAB
code should demonstrate how to execute the exported functions. The required MATLAB code can be
only a few lines:

input1 = [1 4 7; 2 5 8; 3 6 9];
input2 = [1 4 7; 2 5 8; 3 6 9];
addoutput = addmatrix(input1,input2);

This code must also follow all the same guidelines outlined for the Create New Sample option.

You can also choose not to include a sample driver file at all during the packaging step. If you create
your own driver code in the target language, you can later copy and paste it into the appropriate
directory once the MATLAB functions are packaged.

Specify Files to Install with Application


The compiler packages files to install along with the ones it generates. By default, the installer
includes a readme file with instructions on installing the MATLAB Runtime and configuring it.

These files are listed in the Files installed for your end user section of the app.

To add files to the list, click , and select the file from the file explorer.

JAR files are added to the application class path as if you had called javaaddpath.

Caution Removing the binary targets from the list results in an installer that does not install the
intended functionality.

3-6
Customize an Application

When installed on a target computer, the files listed in the Files installed for your end user are
saved in the application folder.

Additional Runtime Settings


Type of Packaged Description Additional Runtime Settings Options
Application
Standalone • Do not display the
Applications Windows Command
Shell (console) for
execution — If you
select this option on a
Windows platform,
when you double-click
the application from
the file explorer, the
application window
opens without a
command prompt.
• Create log file —
Generate a MATLAB
log file for the
application. The
packaged application
can't create a log file if
installed in the C:
folder on Windows
because the
application does not
have write permission
in that folder.

3-7
3 Customizing a Compiler Project

Type of Packaged Description Additional Runtime Settings Options


Application
Excel Add-Ins • Register the
component for the
current user
(Recommended for
non-admin users) —
This option enables
registering the
component for the
current user account.
It is provided for users
without admin rights.
• Create log file —
Generate a MATLAB
log file for the
application. The
packaged application
can't create a log file if
installed in the C:
folder on Windows
because the
application does not
have write permission
in that folder.

See Also
applicationCompiler | libraryCompiler

More About
• “Create Standalone Application from MATLAB”
• “Create Excel Add-In from MATLAB” on page 2-8
• “Generate a C++ mwArray API Shared Library and Build a C++ Application” (MATLAB
Compiler SDK)
• “Generate a C++ MATLAB Data API Shared Library and Build a C++ Application” (MATLAB
Compiler SDK)

3-8
Manage Support Packages

Manage Support Packages


Using a Compiler App
Many MATLAB toolboxes use support packages to interact with hardware or to provide additional
processing capabilities. If your MATLAB code uses a toolbox with an installed support package, the
app displays a Suggested Support Packages section.

The list displays all installed support packages that your MATLAB code requires. The list is
determined using these criteria:

• the support package is installed


• your code has a direct dependency on the support package
• your code is dependent on the base product of the support package
• your code is dependent on at least one of the files listed as a dependency in the mcc.xml file of
the support package, and the base product of the support package is MATLAB

Deselect support packages that are not required by your application.

Some support packages require third-party drivers that the compiler cannot package. In this case,
the compiler adds the information to the installation notes. You can edit installation notes in the
Additional Installer Options section of the app. To remove the installation note text, deselect the
support package with the third-party dependency.

Caution Any text you enter beneath the generated text will be lost if you deselect the support
package.

Using the Command Line


Many MATLAB toolboxes use support packages to interact with hardware or to provide additional
processing capabilities. If your MATLAB code uses a toolbox with an installed support package, use
the-a flag with mcc command when packaging your MATLAB code to specify supporting files in the

3-9
3 Customizing a Compiler Project

support package folder. For example, if your function uses the OS Generic Video Interface
support package, run the following command:

mcc -m -v test.m -a C:\MATLAB\SupportPackages\R2016b\toolbox\daq\supportpackages\daqaudio -a 'C:\

Some support packages require third-party drivers that the compiler cannot package. In this case,
you are responsible for downloading and installing the required drivers.

3-10
4

The Function Wizard

• “Execute Functions and Create Macros” on page 4-2


• “End-to-End Deployment of MATLAB Function” on page 4-16
4 The Function Wizard

Execute Functions and Create Macros


In this section...
“What Can the Function Wizard Do for Me?” on page 4-3
“Installation of the Function Wizard” on page 4-3
“Function Wizard Start-Up” on page 4-4
“Workflow Selection for MATLAB Functions Ready for Deployment” on page 4-5
“Defining Functions Ready to Execute” on page 4-5
“Function Execution” on page 4-13
“Macro Creation” on page 4-13
“Macro Execution” on page 4-13
“Microsoft Visual Basic Code Access (Optional Advanced Task)” on page 4-14
“For More Information” on page 4-15

Warning The option to build and package MATLAB code from within the Function Wizard for Excel
add-ins will be removed in a future release. To create an Excel add-in, use the Library Compiler app.

Not recommended starting in R2020a

If your MATLAB function is ready to be deployed on page 5-9 and you have already built your add-
in and COM component, follow this workflow to incorporate your built COM component into
Microsoft Excel using the Function Wizard. To follow the workflow in this section effectively, you must
run “Create Excel Add-In from MATLAB” on page 2-8.

The Function Wizard also allows you to iteratively test, develop, and debug your MATLAB function.
Using this end-to-end workflow assumes you are still in the process of developing your MATLAB
function for deployment. See “End-to-End Deployment of MATLAB Function” on page 4-16 for
complete instructions for this workflow.

See “Choose Function Deployment Workflow” on page 2-7 for further details.

4-2
Execute Functions and Create Macros

Key Tasks for the End User

Task Reference
1. Install the Function Wizard. “Installation of the Function Wizard” on page 4-
3
2. Start the Function Wizard. “Function Wizard Start-Up” on page 4-4
3. Select the option to incorporate your built “Workflow Selection for MATLAB Functions
COM component into Microsoft Excel. Ready for Deployment” on page 4-5
4. Define the new MATLAB function you want to “Defining Functions Ready to Execute” on page 4-
prototype by adding it to the Function Wizard and 5
establishing input and output ranges.
5. Test your MATLAB function by executing it “Function Execution” on page 4-13
with the Function Wizard.
6. Create a macro. “Macro Creation” on page 4-13
7. Execute the macro you created using the “Macro Execution” on page 4-13
Function Wizard.
8. Optionally inspect or modify the Microsoft “Microsoft Visual Basic Code Access (Optional
Visual Basic code you generated with the COM Advanced Task)” on page 4-14
component. Optionally, attach the macro you
created to a GUI button.

What Can the Function Wizard Do for Me?


The Function Wizard enables you to pass Microsoft Excel (Excel 2000 or later) worksheet values to a
compiled MATLAB model and then return model output to a cell or range of cells in the worksheet.

The Function Wizard provides an intuitive interface to Excel worksheets. You do not need previous
knowledge of Microsoft Visual Basic for Applications (VBA) programming.

The Function Wizard reflects any changes that you make in the worksheets, such as range selections.
You also use the Function Wizard to control the placement and output of data from MATLAB functions
to the worksheets.

Note The Function Wizard does not currently support the MATLAB sparse, and complex data
types.

Installation of the Function Wizard


Before you can use the Function Wizard, you must first install it as an add-in that is accessible from
Microsoft Excel.

After you install the Function Wizard, the entry MATLAB Functions appears as an available
Microsoft Excel add-in button.

Using Microsoft Excel 2010 or newer

1 Click the File tab.


2 On the left navigation pane, select Options.

4-3
4 The Function Wizard

3 In the Excel Options dialog box, on the left navigation pane, select Add-Ins.
4 In the Manage drop-down, select Excel Add-Ins, and click Go.
5 In the Add-Ins dialog box, click Browse.
6 Browse to matlabroot/toolbox/matlabxl/matlabxl/arch, and select
FunctionWizard2007.xlam. Click OK.
7 In the Excel Add-Ins dialog, verify that the entry MATLAB Compiler Function Wizard is
selected. Click OK.
8 Ensure the Home tab of the Microsoft Excel Ribbon contains the Function Wizard tile.

Using Excel 2007

1 Start Microsoft Excel.


2 Click the Office Button
(

) and select Excel Options.


3 In the left pane of the Excel Options dialog box, click Add-Ins.
4 In the right pane of the Excel Options dialog box, select Excel Add-ins from the Manage drop-
down box.
5 Click Go.
6 Click Browse. Navigate to matlabroot\toolbox\matlabxl\matlabxl\arch and select
FunctionWizard2007.xlam. Click OK.
7 In the Excel Add-Ins dialog box, verify that the entry MATLAB Compiler Function Wizard is
selected. Click OK.

Using Excel 2003

1 Select Tools > Add-Ins from the Excel main menu.


2 If the Function Wizard was previously installed, MATLAB Compiler Function Wizard appears
in the list. Select the item and click OK.

If the Function Wizard was not previously installed, click Browse and navigate to matlabroot
\toolbox\matlabxl\matlabxl folder. Select FunctionWizard.xla. Click OK.

Function Wizard Start-Up


Start the Function Wizard in one of the following ways. When the wizard has initialized, the Function
Wizard Start Page dialog box displays.

Using Microsoft Excel 2007 or newer versions of Excel

In Microsoft Excel, on the Microsoft Office ribbon, on the Home tab, select Function Wizard.

You can also access Function Wizard from the File tab.

1 Select File > Options > Add-Ins from the Excel main menu.
2 Select Function Wizard.

4-4
Execute Functions and Create Macros

Workflow Selection for MATLAB Functions Ready for Deployment


After you have installed on page 4-3 and started on page 4-4 the Function Wizard, do the following:

1 From the Function Wizard Start Page, select the option I have an Add-in component that was
built in MATLAB with the Deployment Tool that I want to integrate into a workbook.
2 Click OK. The Function Wizard Control Panel opens with the Add Function button enabled.

The Function Wizard Control Panel for Working with MATLAB Functions Ready for Deployment

Tip To return to the Function Wizard Start Page, click Start Over.

Defining Functions Ready to Execute


1 Define the function you want to execute to the Function Wizard. Click Add Function in the Set
Up Functions area of the Function Wizard Control Panel. The MATLAB Components dialog box
opens.
2 In the Available Components area of the MATLAB Components dialog box, select the name of
your component (xlmagic) from the drop-down box.

4-5
4 The Function Wizard

3 Select the function you want to execute (mymagic) from the box labeled Functions for Class
xlmagic.
4 Click Add Function. The Function Properties dialog box opens.

Tip The Function Syntax and Help area, in the Function Properties dialog box, displays the
first help text line (sometimes called the H1 line) in a MATLAB function. Displaying these
comments in the Function Properties dialog box can be helpful when deploying new or unfamiliar
MATLAB functions to end-users.
5 Define input argument properties as follows.

a On the Input tab, click Set Input Data. The Input Data for n dialog box opens.

b Specify a Range or Value by selecting the appropriate option and entering the value. If the
argument refers to a structure array (struct), select the option This is a MATLAB
structure array argument. See “Working with Struct Arrays” on page 4-9 for
information on assigning ranges and values to fields in a struct array.

Caution Avoid selecting ranges using arrow keys. If you must use arrow keys to select
ranges, apply the necessary fix from the Microsoft site: https://mskb.pkisolutions.com/kb/
291110.

Note Select the Auto Recalculate on Change option to force Microsoft Excel to
automatically recalculate the spreadsheet data each time it changes.

4-6
Execute Functions and Create Macros

c Click OK.

Tip To specify how MATLAB Compiler for Excel add-ins handles blank cells (or cells containing
no data), see “Empty Cell Value Control” on page 4-8.
6 Define output argument properties as follows.

a On the Output tab, click Set Output Data. The Output Data for y dialog box appears,
where y is the name of the output variable you are defining properties of.

Tip You can also specify MATLAB Compiler to Auto Resize, Transpose or output your data
in date format (Output as date). To do so, select the appropriate option in the Argument
Properties for y dialog box.
b Specify a Range. Alternately, select a range of cells on your Excel sheet; the range will be
entered for you in the Range field.

Caution Avoid selecting ranges using arrow keys. If you must use arrow keys to select
ranges, apply the necessary fix from the Microsoft site: https://mskb.pkisolutions.com/kb/
291110.
c Select Auto Resize if it is not already selected.
d Click Done in the Output Data for y dialog box.
e Click Done in the Function Properties dialog box.

4-7
4 The Function Wizard

mymagic now appears in the Active Functions list of the Function Wizard Control Panel.

Empty Cell Value Control

You can specify how MATLAB Compiler processes empty cells, allowing you to assign undefined or
unrepresented (NaN, for example) data values to them.

To specify how to handle empty cells, do the following.

1 Click Options in the Input Data for N dialog box.

The Input Conversion Options dialog box opens.

4-8
Execute Functions and Create Macros

2 Click the Treat Missing Data As drop-down box.


3 Specify either Zero or NaN (Not a Number), depending on how you want to handle empty cells.

Working with Struct Arrays

To assign ranges to fields in a struct array, do the following:

1 If you have not already done so, select This is a MATLAB structure array argument in the
Input Data for n dialog box and click OK.

The Input Data for Structure Array Argument n dialog box opens.

4-9
4 The Function Wizard

2 The Function Wizard supports Vector and Two-dimensional struct arrays organized in either
Element by Element or Plane organization, for both input and output.

In the Input Data for Structure Array Argument n dialog box, do the following:

a In the Structure Array Organization area, select either Element by Element Organization
or Plane Organization.
b Click Add Field to add fields for each of your struct array arguments. The Field for
Structure Array Argument dialog box opens.

4-10
Execute Functions and Create Macros

3 In the Field for Argument dialog box, do the following:

a In the Name field, define the field name. The Name you specify must match the field name
of the structure array in your MATLAB function.
b Specify the Range for the field.

Caution Avoid selecting ranges using arrow keys. If you must use arrow keys to select
ranges, apply the necessary fix from the Microsoft site: https://mskb.pkisolutions.com/kb/
291110.

4-11
4 The Function Wizard

c Click Done.

How Structure Arrays are Supported

MATLAB Compiler supports one and two-dimensional MATLAB structure arrays.

The product converts data passed into structure arrays in element-by-element organization or plane
organization. See MATLAB Programming Fundamentals for more information about all MATLAB data
types, including structures.

Deploying Structure Arrays as Inputs and Outputs

If you are a MATLAB programmer and want to deploy a MATLAB function with structure arrays as
input or output arguments, build Microsoft Excel macros using the Function Wizard and pass them
(with the Excel add-in and COM component) to the end users. If you can’t do this, let your end users
know:

• Which arguments are structure arrays


• Field names of the structure arrays

Using Macros with Struct Arrays

The macro generation feature of MATLAB Compiler for Excel add-ins works with struct arrays as
input or output arguments. See “Macro Creation” on page 4-13 if you have a MATLAB function you
are ready to deploy. See “Microsoft Excel Add-In and Macro Creation Using the Function Wizard” on
page 4-33 if you are using the Function Wizard to create your MATLAB function from scratch. See
“Choose Function Deployment Workflow” on page 2-7 for more information on both workflows.

4-12
Another Random Scribd Document
with Unrelated Content
"Marshal Zabern," said the voice of Ravenna, "as you value the
throne of the princess, come not one step farther. Mark well what is
in my hand."
The window of the oratory, which before had been shut, was now
wide open, and the moonlight fell upon the lofty figure and pale face
of the cardinal, who was standing erect on one side of the altar. In
his right hand he held a dove, to the neck of which a letter was
attached. The sight kept the three men dumb and motionless, for
they instantly divined that the bird was a carrier-pigeon.
Ravenna's Italian guile had been more than a match for Zabern's
subtlety. His object in kneeling before the altar had not been to pray,
but to release the dove which had been attached to it by a silken
thread—a dove purposely kept for emergencies. What captain of the
guard on arresting the archbishop would be so stern-natured as to
refuse his prisoner a few minutes' prayer in his private oratory?
Ravenna, on releasing the dove, had affixed the letter to its neck,
performing the feat so guardedly, that though he had been watched,
now by Zabern, and now by Nikita, his movements had not given
rise to suspicion.
"Listen," cried Ravenna, raising his left hand warningly. "If you enter
I quit my hold of the dove. You observe the letter. Let me tell you
what it contains."
"Say on," returned Zabern with affected indifference. "Your ten
minutes have not yet expired."
"This evening," began the cardinal, "and just prior to your arrival I
penned a letter intended for the Czar's perusal. That letter now
hangs from this dove's neck. It contains three statements. Firstly,
that the Princess of Czernova is not Natalie Lilieska; secondly, that
the Czernovese Charter is a forgery from the hand of Katina
Ludovska; thirdly, that the Convent of the Transfiguration contains
ample evidence of a conspiracy for the emancipation of Poland. Each
of these facts, singly, if known to the Czar, would be sufficient to hurl
the princess from her throne. If this dove should fly forth it would be
in my nephew's house at Zamoska within thirty minutes; an hour
more, and Redwitz would be in the camp of the Czar. Thus, then, do
I make my terms. Approach to do me hurt, and I release the dove.
Retire from the palace, give me my life, and I swear by all that I
hold holy to refrain from endangering the throne of the princess. It
is within your power to murder me, but the murder will be dearly
purchased, for it will bring utter ruin upon Czernova."
"Idle vaunting!" said Zabern. "All know that the carrier-pigeon flieth
not in the dark."
"This dove has ere now found its way to Zamoska by moonlight."
That the cardinal spoke truth when he declared that the letter
contained the weighty secrets Zabern did not doubt. Therefore to
advance with intent to slay would be fatal to the interests of the
princess; and yet to retire, leaving Ravenna to his own devices
would be equally fatal, for Zabern knew full well that the cardinal's
most solemn oath was not to be trusted. So soon as the trio should
withdraw, so soon as Ravenna should be released from the fear of
their presence, he would laugh at their simplicity, and would carry
out his evil work against the princess, ay, and with more
determination than ever, embittered as he would be by the attempt
made upon his life. It was a terrible dilemma.
The trio stood upon the threshold of the oratory, immovable,
irresolute, silent, gazing at the cardinal, who in turn kept his eyes
fixed upon them like a prisoner waiting for the verdict of life or
death.
"No terms with a Jesuit," muttered Zabern under his breath. "Nikita,
you are the best shot. Draw your pistol, and shoot, not the cardinal,
but the dove."
As Zabern spoke he moved slightly to one side, in order to screen
the movements of his henchman.
Directly afterwards a report rang out, startlingly loud in that small
chamber. It was accompanied by a sharp cry of anguish from the
cardinal, and by a swift forward rush on the part of his foes, each
eager to pounce upon the fallen bird.
But, by a strange mischance, Nikita, who was considered to be
second only to Katina herself in the handling of the pistol, had
somehow failed to hit a conspicuous object seventeen feet away.
The bullet had penetrated the wrist of the cardinal, whose hand had
involuntarily relaxed its hold, with the result that the startled dove
was now flying forth through the open casement.
With the air of one mad, Zabern pulled Nikita towards the window,
and, hurling Ravenna aside, he thrust his own pistol into the
trooper's hand.
"Shoot, Nikita, shoot in God's name," he cried, pointing to the dove,
whose white form was clearly defined against the dark blue sky.
"The fate of all Czernova rests on your aim."
The bird, as if doubtful what direction to take, was moving slowly
round in a series of spirals and rising higher and higher each
moment. Nikita pointed his weapon, raising it gradually with the
ascent of the dove, till, deeming himself certain of his aim, he drew
the trigger. A second shot rang out. Both men looked, expecting the
instant fall of the dove, but the winged messenger remained unhurt,
and apparently having chosen its route, flew off in a straight line,
and immediately disappeared over the tree-tops.
"By heaven, you've missed again!" cried Zabern, his dismay being
lost for the moment in wonder that Nikita's hand should have so
strangely lost its cunning.
"God's curse is on me to-night," said Nikita, flinging the pistol from
him. "Who," he added, with a touch of Slavonic superstition, "who
can shoot a dove, symbol of the Holy Ghost?"
"Symbol of the holy devil!" cried Zabern. "Where's the cardinal?"
In his eagerness to mark the effect of Nikita's second shot Gabor
had likewise pressed forward to the casement, forgetful of Ravenna,
who, taking advantage of this negligence, picked himself up from the
corner where Zabern had flung him, and ran from the oratory into
the library. The wondering police next day traced his course over the
carpet by the blood-drops that fell from his shattered wrist.
But in a moment more the avenging Zabern was after him, his sabre
gleaming in his hand.
The cardinal had reached the locked door of the library: his
unwounded hand had turned the key; his fingers were already upon
the door-handle when Zabern, with a laugh of horrid glee, clutched
him by the collar of his cassock with the same hand that held the
sabre, and pulled him backward upon his knees.
The agony of the situation forced from Ravenna a yell that curdled
the blood of the treacherous steward who kept watch at the foot of
the staircase, but it had no effect upon Zabern.
"You paid no heed to Natalie's screams, nor will I to yours."
He thought no more now of safeguarding himself by imparting to the
murder the appearance of suicide.
"To hell, and say that Zabern sent you."
Foaming with fury, he dealt not one, but many strokes at the
kneeling, swaying figure, with its feebly upraised hands. Nikita and
Gabor, equally frenzied, joined in the savage work.

The three miserable men wiped their bloody sabres upon the
window-curtains, and stared down upon the carpet at something
which had once been a man.
The clock-tower of the cathedral now sent forth the sweet and pretty
carillon that always heralded the striking of the hour. Then after a
solemn interval came the first peal of midnight.
"The princess's coronation day!" said Nikita.
"Humph! will there be any coronation?" muttered Zabern.
"Hark to the shouting!" said Gabor.
From every quarter of the capital, from the groups moving to and fro
along the route of the intended procession, from spacious square
and narrow alley, from the brilliantly illuminated hotel, and from the
obscure private dwelling, came the sound of cheering, gradually
swelling into one prolonged universal roar. The gala-day had come at
last!
Zabern with a grim smile looked towards the north. The heaven in
that direction was tinged with a red glow from the thousands of
watch-fires in the Czar's camp—that camp towards which the swift-
flying dove was now winging its course with the tidings fatal to
Czernova. How long would it be ere that huge array came pouring
across the border to depose the princess, and to establish the duke
upon—
Zabern started.
Ere the shouting of the joyous populace had died away, a new and
startling sound was reverberating through the night air. It was the
boom of a single cannon, and that at no great distance. Its
significance was intuitively divined by Zabern.
"The Citadel-gun!" he cried, recoiling from the window. "By God, the
duke has escaped!"
CHAPTER XVII

THE BEGINNING OF THE CORONATION


The morning of Barbara's coronation broke soft and sunny; it
seemed almost impossible that anything disastrous could happen on
a day so fair.
Prior to setting off for the cathedral the princess entertained her
ministers at breakfast. She herself occupied the head of the table,
with Radzivil at her right hand and Zabern at the left. Dorislas was
absent in command of the ten thousand appointed to guard the
frontier.
So far no hostilities had occurred. Successive couriers arriving at
intervals of every half-hour continued to report that the Russian
forces still preserved their position of the previous afternoon,—a
position about a mile distant from the Czernovese border. There was
no movement on their part suggestive of coming invasion. The more
hopeful of the ministers, therefore, began to pluck up courage, and
tried to believe that the Czar's army had really mustered for the
customary autumn manœuvres, and not for the purpose of
preventing the coronation.
Zabern did not share in these hopeful views; none knew better than
he did the magnitude of the peril that overhung Czernova. In
reporting the cardinal's death to the princess Zabern had suppressed
some details, and hence Barbara was unaware that a dove had flown
off to Zamoska bearing a letter, which, if it should reach the Czar's
hands, would most assuredly result in her dethronement. From very
pity he withheld the fact.
"She will learn it soon enough," he thought. "Why add to evil the
anticipation of it?"
During the course of the breakfast many comments were made upon
the murder of Cardinal Ravenna.
"A terrible and mysterious affair!" said Radzivil, greatly shocked by
the tragedy, and completely ignorant as to its authors. "The
physicians assert that there are no less than eighteen wounds upon
the body."
"Five less than Julius Cæsar received," commented Zabern
irrelevantly.
"You offer a reward, I presume, for any information that shall lead to
the detection of the assassins?" said the premier to Zabern, who, as
Minister for Justice, was head of the department that took
cognizance of crime.
"Not a rouble note," replied Zabern bluntly.
"That's contrary to your usual practice."
"Why should I offer a reward when I know who the—ah!—assassins
are? There were three of them to the deed."
"You know them? And yet they have not been seized!"
"I have weighty reasons for deferring their arrest."
"Delay may end in their escape."
"The chief assassin cannot escape from me. The police know him
and have their eye upon him whenever he walks abroad. I can put
my finger upon him as easily as I now lay hand upon this coat," said
Zabern smiling, and suiting the action to the word.
Radzivil was about to press for further enlightenment, but Barbara
checked him.
"The subject is distressing to me," she said with a look that
confirmed her words.
"Your Highness, I crave pardon," said the premier.
Though Barbara fully believed that no one had ever merited death
more than Ravenna, yet the deed lay heavy on her mind. Not even
the thought of the many maidens, her own sister among the
number, sacrificed to the unholy desires of the cardinal, could blind
her to the fact that in sending Zabern to slay him she had committed
a crime.
No such scruple, however, troubled the conscience of the marshal,
whose only regret was that he had not despatched the duke
likewise, while it lay in his power to do so.
Ere coming to the breakfast he had witnessed the execution of the
deputy Lesko Lipski and the spy Ivan Russakoff with the feeling,
however, that it was but sorry justice to shoot the agents, while the
more guilty principal was at large.
"You have no tidings of Bora, I presume?" said Barbara turning to
the marshal.
"None—so far, your Highness," replied Zabern. "But, oh!" he added
with mingled surprise and satisfaction, "here comes one who should
be able to explain the mystery of the duke's escape."
All eyes had turned towards a door which had just opened, giving
ingress to a file of soldiers; they were under the command of Gabor,
and escorted in their midst Miroslav, the governor of the Citadel.
"Your Highness," said Gabor, advancing and saluting, "I came upon
the governor in the act of departing from the city. Thinking that you
might like to interview him, I took the liberty of arresting him on my
own authority."
"You have done well," replied Barbara; and then turning a cold face
upon the governor, she said: "What defence have you to make,
Miroslav? You received orders to exercise special vigilance over your
prisoner, the Duke of Bora, and yet he contrived to escape."
"And with my connivance, so please your Highness."
"Traitor!" said Zabern, starting up, and half drawing his sword, "you
have signed your death-warrant."
"Your Highness, hear my story ere condemning me. At eleven o'clock
last night I was informed that a man stood at the gate of the Citadel
demanding an interview with me. I sent to ascertain his name and
business. 'Carry that to your master,' said the stranger, pencilling a
few words on a card, and enclosing it within an envelope. On
opening the envelope this is what I beheld."
Here Miroslav drew forth a small card, which Gabor conveyed to the
princess, who started at sight of the words that were written upon it.
She handed the note to Radzivil, whose face immediately expressed
the utmost consternation. He tendered the card to Zabern, who in
turn passed it to the minister beside him, and thus amid a death-like
silence it went the round of the table.
And the words of the note were these,—

You are herewith commanded to release the Duke of Bora. Delay will
mean death to you.
NICHOLAS PAULOVITCH
Czar of all the Russias.

"When I saw that signature," continued Miroslav, "I gave orders that
the visitor should be instantly admitted. On entering the room he
commanded my servant to retire, and then when he had withdrawn
the cloak from his face I saw that it was indeed the Emperor
Nicholas. 'Have you given command for the release of my kinsman?'
were his first words. Vain was it for me to protest that I could
receive such an order only from the princess herself. 'I am the
suzerain of Czernova, and therefore above the princess,' was his
reply."
"Ha!" said Barbara, with a flash of her eyes. "And you acknowledged
his suzerainty?"
"Your Highness is great, but the Czar is greater. Who is like the
mighty Nicholas?"
"No one on earth, Miroslav; for which fact may the saints be
praised!" remarked Zabern.
"Your Highness, I was so awed by the emperor's majestic presence,
by his authoritative manner, by the thought of his empire and power
that I could not do otherwise than obey him. The marshal himself
would have done the like, had he been in my place."
Zabern repudiated the statement with a scornful laugh.
"I brought the duke to the presence of the emperor, and the two
withdrew, going I know not where. Fearing your Highness's
displeasure, I myself quitted the Citadel, intending to fly from
Czernova. I throw myself upon your Highness's mercy."
"It was your duty, Miroslav," returned Barbara, "to retain your
prisoner, even at the hazard of your life. In taking orders from a
foreign sovereign you have committed an act of treason. Gabor, see
that the governor be kept in the palace here till our return from the
cathedral. We will then decide as to his punishment."
Gabor saluted, and the troop retired with their prisoner.
"The Czar secretly in our city!" murmured Radzivil, in a tone of
dismay. "What is his object?"
"No good to our rule, count," replied Barbara, quietly.
The secret visit of the Czar to Slavowitz, and his act in releasing the
Duke of Bora, had so sinister an aspect that the hopeful ones among
the ministry returned at a bound to their previous state of doubt.
Were they about to witness a coronation or a dethronement? Was
the Czar preparing to intervene in the ceremony? Would the
solemnity in the cathedral end amid the mockery and the triumph of
the Muscovite faction? With a feeling of pity they glanced at their fair
young ruler, who for her part showed no sign of fear in this great
crisis. They recognized that if she should fall, she would fall with
dignity.
The breakfast ended, and Barbara retired to dress for the coming
ceremony.
Outside, in the wide extent of ground fronting the Vistula Palace, the
long line of the procession was slowly forming under the direction of
marshals and heralds.
Part of the procession consisted of a sort of historic pageant; its
members, attired in costumes that recalled every period of Polish
history, carried trophies and emblems, calculated to stir the patriotic
enthusiasm of the populace.
In this pageant Katina Ludovska bore part, by far the most charming
of the maidens present, clad as she was in a dainty corselet of
silvered mail, above a dark-blue satin skirt flowered with gold.
Mounted upon a beautiful bay, she bore proudly aloft a famous
historic memorial, a standard captured by King Sigismund at the
taking of Moscow, its white silken folds distinctly stamped with the
impress of a bloody hand, a ghastly testimony to the struggle that
had once raged around it.
In riding along the line of the procession, Zabern stopped and
addressed a few words to his affianced.
"Not pasteboard and tinsel, I trust?" he said, with a smile, and
referring to the sword by her side.
"Real steel," replied Katina, exhibiting the blade.
"Good! 'Tis well to go armed on such a day as this. We shall be
fighting for our liberties ere long."
"Death before submission," replied Katina, with a brave light in her
eyes that made Zabern love her the more.
The din caused by the marching of soldiers, the neighing of steeds,
the rolling of carriage-wheels, the snarling of silver trumpets, the
crisp, sharp word of command floated upward to Barbara's ears as
she sat undergoing her toilet at the hands of her ladies. She
wondered, as she had wondered many times that morning, how it
would all end, for assuredly no coronation could ever have been
heralded with more sinister auspices than her own.
Partly with a view to picturesque effect, and partly that the populace
along the line of route might have a clear and uninterrupted view of
their princess, it had been decided that she should proceed to the
cathedral mounted upon a white palfrey.
Barbara had been somewhat disposed at first to shrink from this
exposure to public gaze, but had finally consented to the
arrangement, won over by the argument that as the people would
assemble for the express purpose of seeing her, it would be a
disappointment to them to catch but a glimpse of their ruler through
the windows of a state-coach.
To Radzivil and Zabern had been given the honor of riding side by
side with the princess, though the marshal cared much less for the
honor than for the opportunity afforded him of exercising guard over
her person, since he was not without apprehension that some
fanatic Muscovite might attempt her life during her progress through
the streets.
The procession was timed to start at ten o'clock, and as the hour
drew near Zabern and the premier rode to the entrance of the
palace, and there waited the coming of the princess.
The marshal was mounted upon a magnificent black charger, and
made a splendid figure, for he wore the old picturesque Polish
costume, and sparkled with diamonds from plume to spur.
"And to think," he mused in the interval of waiting, "to think that
Captain Woodville has not yet arrived."
"Captain Woodville?" exclaimed the premier with a start. "Surely the
princess is not recalling him?"
"No, but I am; and his non-arrival is a grave matter for us. Were the
duke still in the Citadel, Woodville's absence might be borne with
equanimity. As it is—but here comes the princess. I must defer my
explanation."
Punctually at one minute to ten, Barbara appeared at the entrance
of the palace, and descending the marble stairs, she mounted her
white palfrey with the assistance of Radzivil.
Zabern at the same moment waved his plumed cap, and
immediately a salvo of artillery from the roof of the palace
proclaimed to the waiting populace that the princess was about to
set off.
Amid the roll of drums, the crash of music, and the pealing of bells
from every steeple in the city, the great brazen gates of the palace
gardens were flung wide, and there rode forth the head of the
procession, the Blue Legion, their lances flashing brightly in the
sunlight.
As they moved out, the sight that met their eyes was sufficient to
stir the blood of the most sluggish. The centre of the road was
empty, but the sidewalks were literally paved with human heads.
Every window, balcony, and roof was alive with spectators. All
Czernova was there, every citizen apparently determined to find a
place somewhere along the line of route. Resolved to obtain a view
somehow of their youthful sovereign, men could be seen clinging in
mid-air to steeples, pediments, cornices, wherever foothold could be
found. From the ground below to the sky above nothing but human
faces.
"Sword of Saint Michael!" muttered Zabern. "A pity all have not been
trained to use the rifle. We might, then, make good defence, even
against the Czar's one hundred thousand."
As soon as Barbara made her appearance, she was greeted with
frenzied cheering. Roar after roar rent the air. Rolling along the
boulevard, and mounting upward to the sky, the sound was almost
loud enough to be heard in the distant camp of the Czar. So great
was the enthusiasm that the troops lining the streets could with
difficulty prevent the populace from pressing forward to touch her.
If any dissentients to her rule were present along the line of route,
they were careful to dissemble their feelings. But who could dissent
from a maiden so sweet and fair? Dressed simply in white silk, she
looked every inch a princess. Her dark hair was without covering,
save for a slender gold diadem, from which there flowed behind a
veil of diaphanous lace.
Tears glistened in eyes that had not been wet for years.
Aged men who had seen the great Kosciusko carried off from the
fatal field of Macicowice; veterans who, like Zabern, had marched
with Napoleon to the fall of Moscow; fugitives from Siberian mines,
with bodies scarred by the iron fetters they had worn; Polish
patriots, survivors of the ill-starred rising of '30—all were gathered
that day in the Czernovese capital to acclaim one destined, so they
believed, to revive the ancient empire of Poland. Many a salute did
Zabern give, as from time to time he caught sight among the crowd
of the face of some old familiar-in-arms.
Barbara, however, though smiling sweetly upon all around, was
inwardly unhappy. A secret voice seemed to whisper, "Deceiver! this
tribute of loyalty is offered to Natalie Lilieska, the lawfully born
daughter of the Princess Stephanie, and not to the Barbara of
doubtful origin."
It was too late now to recede from the rôle she had assumed, and
so amid shouting multitudes she rode on, her progress from the
palace to the cathedral being one continuous scene of triumph,
unmarred by anything of a hostile character.
"It is here, then, that we are to look for the Czar's coup?" muttered
Zabern, as the cavalcade drew in sight of the stately Gothic
cathedral of Saint Stanislas, from every tower of which silver-
tongued bells were pealing jubilant carillons.
Those in the procession whose duty or privilege it was to enter the
cathedral, made their ingress by various doors to their appointed
places; the less fortunate remained drawn up in order around the
edifice.
As Zabern stood upon the broad flight of steps, carpeted with
crimson velvet, and surveyed the vast crowds around, his attention
was suddenly arrested by the sight of a horseman at the far end of a
boulevard which opened upon the cathedral square. As this avenue
was kept clear by the military for the return journey of the princess,
there was nothing to impede the rider's progress, and on he came
with flying rein and bloody spur.
"A courier! a courier!" cried the people, instinctively divining that he
was the bearer of weighty tidings. "What news? What news?"
To their cries, however, the rider remained mute.
"By heaven, it's Nikita!" muttered the marshal.
As the quivering steed drew up at the foot of the cathedral-stairs,
Zabern sprang to meet his orderly.
"Now, marshal," said the latter, "play the Roman, and fall on your
sword's point, for the end has come."
"A good many men shall fall by this blade ere it reaches my heart,"
growled Zabern. "What new trouble do you bring?"
"The chanting of the monks hath ceased; or to be plainer, the
Russian standard is floating over the Convent of the Transfiguration."
"Speak you from hearsay merely?"
"I speak of what I have seen."
"The cardinal laughs at us from hell; this is the first result of his
letter. The Russian invasion has begun, then? Pretty generalship on
the part of Dorislas to let the enemy steal thus upon his rear! And
where are the monks, that they have not fired the powder-
magazine, and sent themselves and their foes flying into the air?
They have sworn an oath to do it rather than let the convent fall into
the hands of the enemy. There would not now have been one stone
upon another if old Faustus had been there."
"It was when on my way back from the camp of Dorislas that I
caught sight of the Muscovite standard on the tower of the convent.
I immediately rode near and perceived the bayonets of the Paulovski
Guards moving to and fro along the battlements. And who should be
in command there but Baron Ostrova, the duke's former secretary—
he whom the princess banished from Czernova. I at once galloped
back to our camp with the news. Dorislas instantly set off with a
thousand men; he has invested the convent; his artillery are ready
planted for shelling the place, and he now awaits orders from you."
"'Orders'?" repeated Zabern with contempt. "My orders should be,
'Consider yourself cashiered for incompetence.' How many Russians
do you suppose there are in the convent?"
"I cannot state the number, marshal—sufficient evidently to
overpower the monks, and to hold the place in case of siege."
"And the rest of the Czar's forces?"
"Are abiding quietly in their camp on the other side of the frontier."
"Gladly would I come, Nikita, to direct operations, but that I dare not
leave the side of the princess, for there is more danger to be
apprehended here than before the convent. Dorislas shall see me
with all speed as soon as the coronation is over. Meantime here are
his orders."
And the marshal wrote upon a slip of paper: "Maintain cordon till my
arrival. Do nothing unless attacked.—ZABERN."
Taking the note, Nikita rode off, his breakneck pace along the
boulevard again exciting the wonder of the populace.
"This holding of the coronation while the foe is on Czernovese
ground might seem a jest to some," murmured Zabern; "yet if, as I
am hoping, the ceremony should tempt the Czar to come forward
personally to oppose the princess's rights, then all may yet be well.
Since Nicholas has chosen to make an armed raid upon our territory,
let him not complain if he should find himself a prisoner of war. And
with the Czar in our hands we shall be masters of the game."
On turning to enter the porch, Zabern was met by the chief court
official, to whom had been committed all the arrangements
connected with the coronation.
"Marshal, the cathedral is full to overflowing, and yet there are
hundreds at the northern porch clamoring for admittance, and all
provided with proper orders."
"Very bad arrangement on your part."
"Not so, marshal. The tickets issued did not exceed the seating
accommodation."
"Ha!" said Zabern, alive to the significance of this statement; "you
mean that there are several hundred persons within who have no
right to be there?"
"That is so, marshal. The whole body of the northern transept is
filled with men who, I am certain, have gained entrance by means of
forged orders. Among these men I recognize many Muscovites, not
ruffians from Russograd, but Muscovites of the nobler and wealthier
class."
"So!" murmured Zabern. "Their plot of the barricades having been
forestalled and thwarted, the enemy are resorting to new
manœuvres."
"Some are in uniform, and some in court dress, and hence they are
armed with swords. If we should attempt to expel them there will be
opposition, tumult, possibly bloodshed. What's to be done?"
"At present, nothing. Let us, if possible, avoid a riot. If they choose
to remain orderly, good; but if it be their object to oppose the
coronation by armed force, then their blood be upon their own
heads."
"And the multitude at the northern porch?"
"Will have to remain there, I fear," replied Zabern, shrugging his
shoulders.
He passed from the porch to the interior of the edifice.
The scene within fairly dazzled the eye. The rich dresses of the
ladies, the splendid military costumes of the men, formed a picture
glowing with color; on all sides were to be seen the sparkle of jewels
and the gleam of scarlet and gold.
As Zabern slowly made his way towards his allotted seat in the choir,
he did not fail to notice certain mocking glances cast at him by the
occupants of the northern transept. Mischief was evidently the
object of their assembling; but inasmuch as they were inferior in
number to the Poles present, and as a word on his part could
instantly set in motion the military both inside and outside the
cathedral, Zabern viewed this Muscovite gathering without any
alarm.
The chancel, elevated considerably above the general level of the
cathedral-pavement, was the cynosure of all eyes.
On the altar were the sacramental vessels, the princely regalia, and
the document supposed to be the original Czernovese Charter, never
publicly exhibited, except at a coronation.
To the left of the altar was an oaken chair in which the princess
would sit, till the time came for her to take her place on the throne.
Respectively north and south of the altar, and each vying with the
other in splendor of vestment, stood the two ecclesiastics who were
to officiate in the ceremony, the Greek Archpastor Mosco, and the
mitred Abbot Faustus; the latter a good man, and a stern old patriot,
quite capable, as Zabern had said, of blowing himself to fragments,
if Polish interests should require such sacrifice.
While Zabern from his place was intently studying the occupants of
the northern transept, under the belief that the Czar was concealed
somewhere among them, a small door in the left wall of the choir
opened, and Barbara entered, bare-headed, and clothed in her
coronation-robe,—a vestment of purple velvet, bordered with
ermine, and gleaming with pearls. Four ladies attended her as train-
bearers.
Awed by the solemnity of the occasion, she was very pale, and with
the glory of the sunlight illumining her figure as she moved forward
with slow and majestic pace, she seemed to her adherents afar off
like a fair vision from another world.
According to the prescribed ritual, the first part of the ceremony
consisted in reading a chapter from one of the Four Evangelists, a
duty which by previous arrangement fell to the lot of Mosco.
As soon, therefore, as Barbara had taken her place in the oaken
chair, she glanced at the archpastor as a sign for him to begin.
Now great importance was attached both by the Poles and the
Muscovites to this reading of the Gospel. The lection was neither
appointed beforehand nor chosen by the ecclesiastic officiating; it
was left to the guidance of chance, or rather, as the Czernovese
themselves believed, to the will of the Deity. The lector, following a
usage of mediæval times, was required to open the holy volume at
random and to read the first chapter upon which his eye should
happen to light. It was believed that the portion thus hit on would
contain something applicable to the person crowned or even
prophetic of the character of the reign.
As Mosco with dignified bearing moved to the lectern, he passed
close to Zabern, whose quick ear instantly detected a peculiar sound
beneath the archpastor's brocaded and jewelled cassock,—a sound
which the marshal could liken only to the trail of a steel scabbard.
"As I live the fellow is armed," he muttered. "A holy prelate with a
sword beneath his gown! There's treason here."
Zabern's first impulse was to spring up, and tearing off Mosco's
gown, to expose him to the assembly as an armed conspirator.
It might be, however, that, like himself, the archpastor anticipated
that there would be rioting and fighting at the coronation, and hence
he had as much right as others to carry arms for his own defence.
Zabern therefore refrained from violence, but his keen eyes were
attentive to every movement of Mosco.
On the brazen lectern, which stood upon the edge of the choir,
directly facing the assembly, lay a volume of the Four Evangelists,
closed and clasped.
Mosco unfastened the clasp, and then evidently wishing to be
thought clear of all suspicion of designedly choosing his lection, he
turned away his head, and with nimble fingers threw open the
volume; and yet in spite of this, Zabern was impressed with the
belief that the Greek prelate knew beforehand at what page the
book was open. He had not forgotten that this reading of the Gospel
had been selected by Mosco himself as his part in the coronation-
ceremony, and he recalled the archpastor's peculiar smile at the time
of his choosing the office. Was the mystery about to be solved?
Turning his eyes upon the opened volume, Mosco began to read.
The lection obtained by this sors sacra proved to be the opening
chapter of the Fourth Gospel.
With a curious anticipatory interest the assembly listened to the
reading, prepared to catch at any verse which might be twisted into
some allusion to the princess and her reign.
Mosco, in a magnificent bass voice and with majestic delivery, read
through five verses. Then, making a momentary pause, he resumed,
changing his tone to one of peculiar emphasis,—
"'There was a man sent from God whose name was John—'"
"And there he is!" cried a voice that rang like a clarion all over the
cathedral, the voice of Feodor Orloff; "there he is! John, Duke of
Bora. People of Czernova, listen to the voice of God."
Scarcely had the words been spoken when the Duke of Bora was
seen emerging from the northern transept.

CHAPTER XVIII

THE GREAT WHITE CZAR


The sudden utterance of Count Orloff, combined with the
simultaneous appearance of the Duke of Bora, caused an electric
thrill to pervade the cathedral.
The holy Gospels, appealed to by a method approved by both
factions alike, seemed to have given a mandate in favor of the duke,
to the confusion of the adherents of the princess. The occupants of
the northern aisle, as well as of the northern transept, gave instant
proof of the side on which their sympathies lay. They rose to their
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookbell.com

You might also like