Closed Thread
Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    09-28-2009
    Location
    Indiana
    MS-Off Ver
    Excel 2003
    Posts
    2

    Smile finding the cell number using C++

    Hi,

    I am new to this forum and this is my first post .

    I am writing a program to access excel spreadsheets using MFC in VS2005. I am able to create the wrapper and able to access excel files, write data into it by specifying a cell number manually.

    Also I can search for data in a given range by using Range.Find() function.
    Code:
    #define vOpt COleVariant((long) DISP_E_PARAMNOTFOUND, VT_ERROR)
    ..
    ..
    Range range;
    ..
    ..
    if(range.Find(COleVariant("09/28"), vOpt, vOpt, vOpt, vOpt, (long) 1, vOpt, vOpt))
    {
    ...
    }
    Can someone please tell me how to get the cell number of that specific cell where the data is located.

    Also is there any good tutorial or help file where I can refer to for further questions.

    Thanks in advance
    -
    Gary

  2. #2
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,445

    Re: finding the cell number using C++

    This is an Excel VBA Forum, not C++. You might have to wait for someone who can help.
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
    Check out the free Excel Toolbar

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)


    Code Tags: Make your code easier for us to read

  3. #3
    Registered User
    Join Date
    09-28-2009
    Location
    Indiana
    MS-Off Ver
    Excel 2003
    Posts
    2

    Smile Re: finding the cell number using C++

    @royUK: Can I atleast get the syntax of VB so that I will try to get a correct syntax in C++.

    Thanks

  4. #4
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,445

    Re: finding the cell number using C++

    What does your code return?
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
    Check out the free Excel Toolbar

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)


    Code Tags: Make your code easier for us to read

  5. #5
    Forum Moderator romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Alibi
    MS-Off Ver
    All
    Posts
    8,262

    Re: finding the cell number using C++

    In VB, Range.Find returns a Range object (or Nothing if the data is not found) but I suspect in C++ it returns something like an IDispatch? If so, you should be able to use a range variable and AttachDispatch to get a reference to the found range (but I am way out of my comfort zone with C++!!)
    Cross-posted here BTW.
    So long, and thanks for all the fish.

  6. #6
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,445

    Re: finding the cell number using C++

    Well spotted RomperStomper.

    Your post does not comply with Rule 8 of our Forum RULES. Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser)to the cross-post. Expect cross-posts without a link to be closed a message will be posted by the moderator explaining why. We are here to help so help us help you!
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
    Check out the free Excel Toolbar

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)


    Code Tags: Make your code easier for us to read

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0