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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
In article news: said:
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.
 
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.

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.
 
Back
Top