Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / September 2004

Tip: Looking for answers? Try searching our database.

how to run a c++ program from excel Macro?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
maryam - 23 Sep 2004 23:59 GMT
Hi
i have some data in excel....I want to perform a series of operations on
them and output the results to excel again. I know that some stuff could be
used with VBA. however in this special case I don't know how to do it.!
ex:
In c++ you could store an array of characters in char[20]
and then look for a certain character in the array. but i don't know how to
do it with VBA!
I want to read "BB-15" from the Cells(1,1) and put BB in one cell and 15 in
another cell. This could easily be done in c++ by a simple search. Can it
also be done in VBA?

if not...is it possible to tell a macro in excel to run a c++ program. and
give what is in the workbook 1 as a txt input to c++. Then make the C++
program to output the result in the same workbook.

thanks

maryam
Daniel James - 24 Sep 2004 14:10 GMT
> In c++ you could store an array of characters in char[20]
> and then look for a certain character in the array. but i don't know how to
> do it with VBA!

It's just Basic ... you use Mid$

You can use the following VBA function to obtain the Nth character of the
contents of an Excel cell

 Function indexchar(chars As String, index As Integer) As String
    indexchar = Mid$(chars, index, 1)
 End Function

Then if cell A1 contains "wombat" and A2 contains 3 and A3 contains
+indexchar(A1,A2) Excel will display "m" in A3.

> if not...is it possible to tell a macro in excel to run a c++ program.
> and give what is in the workbook 1 as a txt input to c++. Then make
> the C++ program to output the result in the same workbook.

Not quite.

You can do two things: You can write a C++ program that uses OLE
Automation to run the whole Excel application under control of the C++
program, or you can write a DLL in C++ and write some VBA glue code around
the DLL so that it can be called from the spreadsheet.

However, for this simple task you don't need to do either.

Cheers,
Daniel.
Daniel James - 25 Sep 2004 14:04 GMT
> You can use the following VBA function to obtain the Nth character of the
> contents of an Excel cell
[quoted text clipped - 5 lines]
> Then if cell A1 contains "wombat" and A2 contains 3 and A3 contains
> +indexchar(A1,A2) Excel will display "m" in A3.

Rereading my own post (isn't that supposed to be a sign madness, or vanity,
or something?) I realize that in trying to answer the OP's question on its
own terms I've neglected to mention that you can do this with the built-in
Excel macro "mid" anyway

So if cell A1 contains "wombat" and A2 contains 3 and A3 contains
+mid(A1,A2,1) Excel will display "m" in A3.

Wood, trees, humbug!

Cheers,
Daniel.
Jens Thiel - 26 Sep 2004 11:06 GMT
maryam,

from the newsgroup I assume you are talking about managed C++. Have a look
here:

 http://ManagedXLL.net/

Jens.
--
Replace MSDN with my first name when replying to my email address!

> Hi
> i have some data in excel....I want to perform a series of operations on
[quoted text clipped - 15 lines]
>
> maryam

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.