Question on chapter 27, COM Add In exercise

Building Customisable High Performance C++ Applications

Question on chapter 27, COM Add In exercise

Postby jessicatan12 » Mon Apr 16, 2012 11:22 am

Hi MR. Duffy,

I purchased your book " Monte Carlo frameworks, Building customisable High performance C++ Application, and i tried to compile the source code from the following cd folder:

file:///Z:/content/Chapter27 - Excel Projects/Black Scholes/

And, i registered the BlackscholesAddin.dll in the registry. It is successfully registered under HKEY_LOCAL_Machine\Microsoft\Office\Excel\AddIns

However, when i open your BlackScholes.xls (from the cd), all the following fields showed " #Name? "





-Put price

-Call price

To test the Com DLL is successfully registered, i written the following internal VBA code, it run successfully, and Result = 2.4679

Private Sub CommandButton1_Click()

Dim tp As New BlackScholes

Dim Result As Double

Dim temp As Double

Result = tp.Price(1, 0.1, 0.2, 95, 0.5, 100, 0.05)

End Sub

But i do not understand why it doesn't work on excel worksheet, meaning the following formula on excel cell returns error ( #Name?) :


Could you please help to assit me? I have done alot of googling.. but no lucks still.
Posts: 3
Joined: Fri Apr 13, 2012 5:24 am

Postby jessicatan12 » Wed Apr 18, 2012 3:58 am

Thanks! Problem solved! This book is fantastic!
Posts: 3
Joined: Fri Apr 13, 2012 5:24 am


Postby jessicatan12 » Wed Jun 26, 2013 3:02 pm

Hi Duffy,

I have a question about ExcelRangeToStlVector(Excel::RangePtr pRange).

Assuming there are 10 filled cells(column vector), but the range selected is 15 rows. The " int rows" below is 15 , rather than 10.

The values in the last 5 cells read into v[index] are "#DEN" ( denormalized number) because the last 5 cells are empty.

int rows=pRange->Rows->Count; // this line return 15 rather than 10

The desired behaviour is rows should be 10 because there are 10 cells with legit values, eventhough a total of 15 cells were highlighted.

My program crashed due to the denormalized numbers are read. Is there a workaround for this?

Thanks for your help in advance.
Posts: 3
Joined: Fri Apr 13, 2012 5:24 am

Postby Cuchulainn » Sat Jun 29, 2013 11:37 am


At the moment the software creates the STL vector based on the number of rows selected.

It might be possible to scan the range beforehand and only then initialise the vector with the corect count.
User avatar
Posts: 677
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Return to Monte Carlo Frameworks (Duffy/Kienitz)

Who is online

Users browsing this forum: No registered users and 1 guest