• C++ Programming for Financial Engineering
    Highly recommended by thousands of MFE students. Covers essential C++ topics with applications to financial engineering. Learn more Join!
    Python for Finance with Intro to Data Science
    Gain practical understanding of Python to read, understand, and write professional Python code for your first day on the job. Learn more Join!
    An Intuition-Based Options Primer for FE
    Ideal for entry level positions interviews and graduate studies, specializing in options trading arbitrage and options valuation models. Learn more Join!

How to create UDF in Excel using C# and Visual Studio 2008

thank a lot
i understand my error, xlwDotNet wasn't installed because i left it grayed when it was installed:oops:
i swichted to xlw 4 and Visual C#2008 because i prefer these version more completed
i followed the video on youtube "howto create a C# XLL addin using XLW&Visual Studio"
everything goes well until i want to build my solution, i have this error:
" MSB3073 : La commande ""C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\..\..\VC\vcpackages\vcbuild" "C:\Users\Julien\Documents\XLL_Project\Addin\DemoXLL.sln" "Debug|Win32"" s'est arrêtée avec le code 9009. "
i was so close to success :(, once again your precious help would be welcome

Hi M,

Which version of Visual Studio do you have installed ? Express or PRO ?

Do you have Visual Studio C++ installed ? Because it is required and if you do not you will need to install it and it should work.
 
thank a lot , you're so strong
i downloaded visual studio C++ 2008 and it works very well, finally i can encode quietly
thank you for your help
 
thank a lot , you're so strong
i downloaded visual studio C++ 2008 and it works very well, finally i can encode quietly
thank you for your help

Welcome.
Do look at the examples packaged with XLW, you may find them useful. There is also one that downloads market data into the spreadsheet from yahoo that students often find helpful
 
We have just released an updated development snapshot of XLW (XLW-5DEV)

The major changes compared to the previous Dev5 release are:

Excel 2010 support
64-bit xll support
Improved multi-threading stability
XLOPER string fixes
http://sourceforge.net/projects/xlw/files/xlw/xlw 5DEV/xlw-5DEV-28Mar2011.exe/downloadYou can grab it from here:

http://sourceforge.net/projects/xlw/files/xlw/xlw%205DEV/xlw-5DEV-28Mar2011.exe/download


Thanks to John Adcock for all his efforts.


It's planned to support building 64 bit dll's with gcc as well as converting all the .NET code in an up and coming dev release.
 

anujjain

Graduate Student
Hello Guys,
I have an excel macro which pulls some data from the oracle database and produces some output. Is it possible to run this macro from a c++ code and then use the output of the macro in the further part of c++ program. Thanks.
 
I don't think you can do it straight away from that code you have in excel but rather there should be a way convert this VBA code into standard CIL instruction readable for every language while executing. Some modification might be required to construct a dll. Not sure though.
 

anujjain

Graduate Student
I can open up an excel sheet and do normal calculations through c++ but can't run the macro. It crashes. So I am making progress but yet to complete it.
 

Yes you can call a VBA function from C++ through the Excel C API. You need to call the function xlUDF .... you should find a reference to it in Steve Daltons book. We will be putting a service for executing VBA functions into the current version of XLW in development.
 
Can anybody tell how to mark the Register for COM Introp checkbox in the build tab? (VS 2010) It is disabled and not sure how to enable it... Thanks
 

anujjain

Graduate Student
I am trying to write data into excel through C++. I am using this code which gives me a compile error.
------------------------------------------------------------------------------------------------------------------------------
CoInitialize(NULL);

Excel::_ApplicationPtr xl;

xl.CreateInstance(L"Excel.Application");

xl->Visible = true;


xl->Workbooks->Open(L"C:\\work\\test1\\tes.xls");

Excel::_WorksheetPtr myWrks(xl->Worksheets->Item["tes"]);
myWrks->Activate();
Excel::_WorksheetPtr pSheet = xl->ActiveSheet;

pSheet->Name = "Chart Data";
Excel::RangePtr pRange = pSheet->Cells;
pRange->Item[2][3] ="Hello World!"
--------------------------------------------------------------------------
error C2664: 'PutItem' : cannot convert parameter 1 from 'const int' to 'const class _variant_t &

When change the Item[2][3] to Item["2"]["3"] it compiles but then crashed at this line.

Any help would be appreciated. Thanks.
 
We are intending to release the first alpha of XLW5 anyday now. For XLW5 we would like to distribute user
contributed projects that may be helpful and informative to the rest of the xlw user community. We
require the contributed source code to be open source but you are free to choose any approved
(http://www.opensource.org/) open source license you like. To contribute your code create a patches tracker at (http://sourceforge.net/tracker/?func=add&group_id=45222&atid=442238)

1. Fill in the Summary Field.

2. Complete and paste the following in the description:

Name : <Project Name>

Author(s) : <Name of all the authors>

Dev Platform : <Stated the dev environments required for your project, eg VS2008, VS2010 , MingW etc>

External Dependencies : <State any dependencies your project may have for example Boost, GSl etc>

License : <please copy and paste here the license under which you wish to contribute your code>

Disclaimer :
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
The names of the XLW Group and its contributors may NOT be used to endorse or promote products
derived from this software without specific prior written permission.

3. Attach an archive (.zip, .tar.gz) of your projects to the tracker [Add Artifact]

Thanks
 
I was trying to just find tutorials on making user defined functions with visual studio C# excel addin and this tutorial has helped me so much.

One thing I did want to point out was right away the BlackScholesAddin.Functions did not appear in the Automation list. I am using VS2010 sp1 and Excel 2007. I got the BlackScholesAddin.Functions to appear in the list after I changed the project properties from using .NET 4.0 to 3.5.

Hopefully that is useful to someone.
 
Top