Solved

Please help compilC# Excel integration code

Posted on 2011-02-22
10
235 Views
Last Modified: 2012-05-11
Dear Friends,

I am not sure what is wrong with the code at the followijng web address, but the code is not compiling with VS 2008. Can someone pleaese look into this?

The code is located at http://support.microsoft.com/kb/303872.

Appreciate your help,

Thanks,
AMita
0
Comment
Question by:deoyagya
10 Comments
 
LVL 23

Expert Comment

by:wdosanjos
Comment Utility
What error message do you get and in what line?
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
And which edition of VS are you using? I don't think the express edition can use it.
0
 

Author Comment

by:deoyagya
Comment Utility
I am using Visual Studio 2008. I am getting the error message at the following line of the code:

            oCommandBar = oExcel.CommandBars.Add("VBAMacroCommandBar",oMissing, oMissing,\);

This is giving me error related to new line character.
0
 
LVL 33

Expert Comment

by:Todd Gerbert
Comment Utility
That's a mal-formed statement - you're passing a backslash as the last parameter, which is not valid.
0
 

Author Comment

by:deoyagya
Comment Utility
Can you give me the working code then.
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 23

Expert Comment

by:wdosanjos
Comment Utility
Try this:

oCommandBar = oExcel.CommandBars.Add("VBAMacroCommandBar",oMissing, oMissing,);
0
 
LVL 23

Expert Comment

by:wdosanjos
Comment Utility
Sorry I meant,

oCommandBar = oExcel.CommandBars.Add("VBAMacroCommandBar",oMissing, oMissing);
0
 

Author Comment

by:deoyagya
Comment Utility
I tried this. But this is not working. I am getting the error message "Add method takes three arguments".
0
 
LVL 23

Accepted Solution

by:
wdosanjos earned 500 total points
Comment Utility
Please try the following.  I was able to compile here (VS2008, .NET 3.5, Excel 2007).

oCommandBar = oExcel.CommandBars.Add("VBAMacroCommandBar", oMissing, oMissing, oMissing);
0
 

Author Comment

by:deoyagya
Comment Utility
Thanks a lot for the help. This is working fine now.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now