Requirements
The following list includes the software that is required to complete this task:
- Visual Studio .NET 2002 or a later version of Visual Studio
- Excel 2000 or a later version of Excel
- Euro Currency Tools add-in
How to install the Euro Currency Tools add-in
To install the Euro Currency Tools add-in, follow these steps:
- Start Excel.
- On the Tools menu, click Add-ins.
- Click to select the Euro Currency Tools
check box, and then click OK.
About the MSoEuro component
The MSoEuro component provides the
Convert method. The
Convert method can convert currencies in the following three ways:
- From a euro nation's currency to euros
- From euros to a euro nation's
currency
- From one euro nation's currency to another
euro nation's currency by using euros as an
intermediary
The
Convert method returns the converted number as a double
variable. The
Convert method takes the following five arguments.
Convert (Value, CurrencyFrom, CurrencyTo, FullPrecision, TriangulationPrecision)
The five arguments are defined in the following list:
- The Value argument is a double variable. This argument is
the number of units of currency that you want to convert.
- The CurrencyFrom argument is a string variable. This
argument is the three letter code that indicates the unit of currency that you are converting from.
- The CurrencyTo argument is a string variable. This
argument is the three letter code that indicates the unit of currency that you are converting to.
- The FullPrecision argument is a Boolean variable. This argument specifies how to display the returned number. If this argument is set to true, all significant digits from the
conversion are displayed. If this argument is set to false, not
all significant digits from the conversion are displayed. By default, this argument is set to false.
- The TriangulationPrecision argument is an integer variable and
is greater than or equal to 3. When the Convert method of the MSoEuro component converts one euro nation's currency to another euro nation's currency, the Convert method can round the intermediate euro value. This argument specifies how many digits to use when the Convert method rounds the intermediate euro value. If you omit this argument, the Convert method does not round the intermediate euro value.
Codes for European currencies
The following currency codes are available in the
Convert method.
Collapse this tableExpand this table
Country/region | Basic unit of currency | ISO code |
Belgium | Franc | BEF |
Luxembourg | Franc | LUF |
Germany | Deutsche Mark | DEM |
Spain | Peseta | ESP |
France | Franc | FRF |
Ireland | Pound | IEP |
Italy | Lira | ITL |
Netherlands | Guilder | NLG |
Austria | Schilling | ATS |
Portugal | Escudo | PTE |
Finland | Markka | FIM |
Greece | Drachma | GRD |
Euro nations | Euro | EUR |
How to use the MSoEuro component to convert euros programmatically
To use the MSoEuro component to convert euros programmatically, follow these steps:
- Start Visual Studio.
- Create a new console application by using Microsoft Visual
Basic or by using Microsoft Visual C#.
- Add a reference to the Microsoft Office Euro
Converter Object Library (Msoeuro.dll).
- Insert the following code into the console
application. For a Microsoft Visual C# console application, insert the following code in
the static void Main method.
MsoEuro.Converter objEuro=null;
try
{
//Use MSOEURO.dll for currency conversion
objEuro=(MsoEuro.Converter) Activator.CreateInstance(Type.GetTypeFromProgID( "MsoEuro.Converter"));
//Show DLL version
Console.WriteLine("msoeuro.dll version : " + objEuro.Version);
}
catch
{
//DLL not found
Console.WriteLine("Please check the Installation of MSOEURO.dll on your PC.");
Console.Read();
System.Environment.Exit(0);
}
//Value for currency conversion
const string CurrencyFrom = "EUR";
const string CurrencyTo = "ITL";
double SourceValue = 1; // 1 Euro
const bool FullPrecision = true;
const int TriangulationPrecision = 5;
double ResultValue;
//Call DLL for currency conversion
ResultValue =objEuro.get_Convert(SourceValue,CurrencyFrom,CurrencyTo,FullPrecision,TriangulationPrecision);
Console.WriteLine("Result is : " + ResultValue);
Console.ReadLine();
For a Visual Basic .NET console application, insert the following
code in the Sub Main method.Dim objEuro As MsoEuro.Converter
Try
'Use MSOEURO.dll for Currency conversion
objEuro = CreateObject("MSOEURO.Converter")
'Show DLL version
Console.WriteLine(�msoeuro.dll version : � & objEuro.Version)
Catch ex As Exception
'DLL not found
Console.WriteLine("Please check the Installation of MSOEURO.dll on your PC.")
Console.Read()
End
End Try
'Default value for Currency conversion
Const CurrencyFrom As String = "EUR"
Const CurrencyTo As String = "ITL"
Dim SourceValue As Decimal = 1 ' 1 Euro
Const FullPrecision As Boolean = True
Const NumDigitsAfterDecimal As Integer = 2
Dim ResultValue As Decimal
'Call DLL for Currency conversion
ResultValue =FormatNumber(objEuro.Convert(SourceValue,CurrencyFrom,CurrencyTo, _
FullPrecision), NumDigitsAfterDecimal)
Console.WriteLine(�Result is : � & ResultValue)
Console.Read()
- Save and then run the console application.
Note You receive the
following output.msoeuro.dll version : 1.0.128
Result is : 1936,27