CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2005
    Location
    United States
    Posts
    526

    A question on automating Excel from a C++ program

    I've got an MFC program that I wrote using Visual C++ 6. I'd like that program to be able to modify an existing MS Excel spreadsheet by opening that spreadsheet and passing arguments to a VB macro stored within it. If it matters, the macro has the form:
    Code:
    Sub AddItem(ItemDesc As String, ItemCount As Integer)
        ' ... lots of stuff happens ... 
    End Sub
    I haven't done anything like this before so am kind of at a loss as to where to begin. I don't need a lot of details; basically I just would like someone to tell me what I should start reading to figure out how to send commands to Excel from a C++ program. Thanks!

  2. #2
    Join Date
    May 2005
    Posts
    4,954

    Re: A question on automating Excel from a C++ program

    Quote Originally Posted by Smasher/Devourer
    I've got an MFC program that I wrote using Visual C++ 6. I'd like that program to be able to modify an existing MS Excel spreadsheet by opening that spreadsheet and passing arguments to a VB macro stored within it. If it matters, the macro has the form:
    Code:
    Sub AddItem(ItemDesc As String, ItemCount As Integer)
        ' ... lots of stuff happens ... 
    End Sub
    I haven't done anything like this before so am kind of at a loss as to where to begin. I don't need a lot of details; basically I just would like someone to tell me what I should start reading to figure out how to send commands to Excel from a C++ program. Thanks!
    Hi Smasher, good to have ya back

    maybe this thread can help you out: How to load an Excel file.

    BTW where is exactly the problem? In activating the macro? Or just load Excel file using automation and control it?

    Cheers
    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers

  3. #3
    Join Date
    Apr 2002
    Location
    Michigan, USA
    Posts
    869

    Re: A question on automating Excel from a C++ program

    For an example of running a macro from VC see :
    Excel Macro
    Verere testudinem! (Fear the turtle)

    Once you can accept the universe as matter expanding into nothing that is something, wearing stripes with plaid comes easy. -Albert Einstein

    Robots are trying to steal my luggage.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured