CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Oct 1999
    Location
    ks
    Posts
    523

    excel in/on dialog box

    what am i missing?

    have gone through countless searches in this forum and google. i want to do the following:

    create an mfc dialog based app that treats excel like a grid control in that
    an excel workbook is placed on the dialog box (preferably through a drag and drop procedure) and employ basic cell i/o operations.

    articles such as http://support.microsoft.com/kb/311546: (How to embed and automate an Excel worksheet by using MFC and Visual C++ 2005 or Visual C++ .NET) are typical of the off point material i find:

    1. they are not written for dialog based apps

    2. i interpret automation to mean control and embedding to make excel
    a child object to the dialog so that click events can alter the excel sheet
    cell values visible on the dialog - the articles i see seem to make no distinction

    3. the article actually provides compilable code - something i rarely find ms
    capable of doing (the article above is a case in point: does not provide
    what i want and does not compile)

    am using vs2005 vc++

    appreciate any insight. thx in advance -
    Last edited by jim enright; February 2nd, 2011 at 02:07 AM. Reason: typos

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: excel in/on dialog box

    What "does not compile"?
    Victor Nijegorodov

  3. #3
    Join Date
    Oct 1999
    Location
    ks
    Posts
    523

    Re: excel in/on dialog box

    the code in the referenced article:

    it compiles through step 6. the addition of the #includes from section 7 at the top of the Embed_ExcelView.cpp file and the inclusion of the remainder of the code in section 7 at the bottom of said cpp file spews forth the
    the messages below (after the >>>>> below)in response to attempted compilation (and further this is an off point app since it is single document not dialog):


    pls note fundamental rejections of the code not related to namespace issues further down in the messages such as:

    C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\comdef.h(322) : see declaration of 'FontPtr'
    1>c:\users\jim\documents\visual studio 2005\projects\embed_excel\embed_excel\debug\excel.tlh(1549) : error C2786: 'BOOL (__stdcall *)(HDC,int,int,int,int)' : invalid operand for __uuidof
    1>c:\users\jim\documents\visual studio 2005\projects\embed_excel\embed_excel\debug\excel.tlh(1549) : error C2923: '_com_IIID' :

    >>>>>>

    1>c:\users\jim\documents\visual studio 2005\projects\embed_excel\embed_excel\CApplication.h(3) : warning C4278: 'RGB': identifier in type library 'C:\\Program Files (x86)\\Microsoft Office\\Office12\\EXCEL.EXE' is already a macro; use the 'rename' qualifier
    1>c:\users\jim\documents\visual studio 2005\projects\embed_excel\embed_excel\CApplication.h(3) : warning C4278: 'RGB': identifier in type library 'C:\\Program Files (x86)\\Microsoft Office\\Office12\\EXCEL.EXE' is already a macro; use the 'rename' qualifier
    1>c:\users\jim\documents\visual studio 2005\projects\embed_excel\embed_excel\CApplication.h(3) : warning C4192: automatically excluding 'IFont' while importing type library 'C:\\Program Files (x86)\\Microsoft Office\\Office12\\EXCEL.EXE'
    1>c:\users\jim\documents\visual studio 2005\projects\embed_excel\embed_excel\CApplication.h(3) : warning C4192: automatically excluding 'IPicture' while importing type library 'C:\\Program Files (x86)\\Microsoft Office\\Office12\\EXCEL.EXE'
    1>c:\users\jim\documents\visual studio 2005\projects\embed_excel\embed_excel\CApplication.h(3) : warning C4278: 'DialogBox': identifier in type library 'C:\\Program Files (x86)\\Microsoft Office\\Office12\\EXCEL.EXE' is already a macro; use the 'rename' qualifier
    1>c:\users\jim\documents\visual studio 2005\projects\embed_excel\embed_excel\CApplication.h(3) : warning C4278: 'CopyFile': identifier in type library 'C:\\Program Files (x86)\\Microsoft Office\\Office12\\EXCEL.EXE' is already a macro; use the 'rename' qualifier
    1>c:\users\jim\documents\visual studio 2005\projects\embed_excel\embed_excel\CApplication.h(3) : warning C4278: 'ReplaceText': identifier in type library 'C:\\Program Files (x86)\\Microsoft Office\\Office12\\EXCEL.EXE' is already a macro; use the 'rename' qualifier
    1>c:\users\jim\documents\visual studio 2005\projects\embed_excel\embed_excel\CApplication.h(3) : warning C4278: 'ReplaceText': identifier in type library 'C:\\Program Files (x86)\\Microsoft Office\\Office12\\EXCEL.EXE' is already a macro; use the 'rename' qualifier
    1>c:\users\jim\documents\visual studio 2005\projects\embed_excel\embed_excel\CApplication.h(3) : warning C4278: 'RGB': identifier in type library 'C:\\Program Files (x86)\\Microsoft Office\\Office12\\EXCEL.EXE' is already a macro; use the 'rename' qualifier
    1>c:\users\jim\documents\visual studio 2005\projects\embed_excel\embed_excel\CApplication.h(3) : warning C4278: 'RGB': identifier in type library 'C:\\Program Files (x86)\\Microsoft Office\\Office12\\EXCEL.EXE' is already a macro; use the 'rename' qualifier
    1>c:\users\jim\documents\visual studio 2005\projects\embed_excel\embed_excel\CApplication.h(3) : warning C4278: 'CopyFile': identifier in type library 'C:\\Program Files (x86)\\Microsoft Office\\Office12\\EXCEL.EXE' is already a macro; use the 'rename' qualifier
    1>c:\users\jim\documents\visual studio 2005\projects\embed_excel\embed_excel\CApplication.h(3) : warning C4278: 'DialogBox': identifier in type library 'C:\\Program Files (x86)\\Microsoft Office\\Office12\\EXCEL.EXE' is already a macro; use the 'rename' qualifier
    1>c:\users\jim\documents\visual studio 2005\projects\embed_excel\embed_excel\debug\excel.tlh(1471) : error C2371: 'FontPtr' : redefinition; different basic types
    1> C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\comdef.h(322) : see declaration of 'FontPtr'
    1>c:\users\jim\documents\visual studio 2005\projects\embed_excel\embed_excel\debug\excel.tlh(1549) : error C2786: 'BOOL (__stdcall *)(HDC,int,int,int,int)' : invalid operand for __uuidof
    1>c:\users\jim\documents\visual studio 2005\projects\embed_excel\embed_excel\debug\excel.tlh(1549) : error C2923: '_com_IIID' : 'Rectangle' is not a valid template type argument for parameter '_Interface'

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: excel in/on dialog box

    Well, I'm sure that you are not the first person who get these errors. Use Google to search for every error description you've got and you will see how other people solved the same problems!
    Example:
    http://www.google.com/search?sourcei...idof&gs_htsa=1
    Victor Nijegorodov

  5. #5
    Join Date
    Oct 1999
    Location
    ks
    Posts
    523

    Re: excel in/on dialog box

    maybe this is just me but would not a better solution be for ms to actually fix their their erroneous "documentation"? i pointed this out as a response to their standard survey at the end of the link. i am not holding my breath and this is hardly an isolated instance.

  6. #6
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: excel in/on dialog box

    The issue is... it's not erroneous.
    Those samples were made for specific versions of VC, and not all of those samples are maintained to continue working for every new version of the compiler that comes around.

    If you are still using VC6, that's a very good possibility of stuff not working. VC6 was not yet standards compliant.

  7. #7
    Join Date
    Oct 1999
    Location
    ks
    Posts
    523

    Re: excel in/on dialog box

    i stated in my orig post that i was using vc2005 not vc6.0

    the title of the cited article specifically mentions vc2005 not vc6.0

    the body of the article explicitly states in its summary:

    This step-by-step article describes how to embed an Excel worksheet in a View object in a single-document interface (SDI) Microsoft Foundation Classes (MFC) application by using Visual C++ 2005 or Visual C++ .NET.

    why bring up vc6.0 as a possible cause of the code not compiling?

    i checked out about 6 google links related to the compiler error issues - none of which led to any solution.

    none of this is related to my original question - treating excel like a grid control ocx and putting it on dialog box.

  8. #8
    Join Date
    May 2009
    Location
    Bengaluru, India
    Posts
    460

    Re: excel in/on dialog box

    since both CView and CDialog are some forms of window controls.. derived by CWnd.. you try to understand how they have done it for CView and on a similar round try embedding xl sheet on the dialog....

  9. #9
    Join Date
    Oct 1999
    Location
    ks
    Posts
    523

    Re: excel in/on dialog box

    "embedding"?? - this is part of the problem. there is confusion of what that means. i take that to mean putting it inside the dialog app ie making it appear just like other like a grid control ocx. apparently that is not the case. i have gotten to the point where i can programatically i/o to the xls but it is all behind the scenes - the xls is not encased in the dialog app.

    googling excel ocx seems to offer some leads on free ocx downloads but
    they turn out to be not free, do not treat xl as an ocs or return a message the link is no lobger available.

    will keep trying and will try to embarass ms in to actually fixing their %*%.

  10. #10
    Join Date
    Oct 1999
    Location
    ks
    Posts
    523

    Re: excel in/on dialog box

    making some progress - found an article that actually attempts automate and
    embed (whatever the hell embed means) excel on a dialog. of course,
    that did not compile but it was a step in the right direction in that the objections from the compiler no longer raised namespace complaints but
    just restricted the complaints to things like redefinitions:

    1>c:\users\jim\documents\visual studio 2005\projects\autoproject\autoproject\debug\excel.tlh(1471) : error C2371: 'FontPtr' : redefinition; different basic types
    1> c:\program files (x86)\microsoft visual studio 8\vc\include\comdef.h(322) : see declaration of 'FontPtr'
    1>c:\users\jim\documents\visual studio 2005\projects\autoproject\autoproject\debug\excel.tlh(1549) : error C2786: 'BOOL (__stdcall *)(HDC,int,int,int,int)' : invalid operand for __uuidof
    1>c:\users\jim\documents\visual studio 2005\projects\autoproject\autoproject\debug\excel.tlh(1549) : error C2923: '_com_IIID' : 'Rectangle' is not a valid template type argument for parameter '_Interface'
    1> c:\program files (x86)\microsoft visual studio 8\vc\platformsdk\include\wingdi.h(3514) : see declaration of 'Rectangle'
    1>c:\users\jim\documents\visual studio 2005\projects\autoproject\autoproject\debug\excel.tlh(1549) : error C3203: '_com_IIID' : unspecialized class template can't be used as a template argument for template parameter '_IIID', expected a real type
    1>c:\users\jim\documents\visual studio 2005\projects\autoproject\autoproject\debug\excel.tlh(1553) : error C2786: 'BOOL (__stdcall *)(HDC,int,int,int,int,int,int,int,int)' : invalid operand for __uuidof
    1>c:\users\jim\documents\visual studio 2005\projects\autoproject\autoproject\debug\excel.tlh(1553) : error C2923: '_com_IIID' : 'Arc' is not a valid template type argument for parameter '_Interface'
    1> c:\program files (x86)\microsoft visual studio 8\vc\platformsdk\include\wingdi.h(2765) : see declaration of 'Arc'
    1>c:\users\jim\documents\visual studio 2005\projects\autoproject\autoproject\debug\excel.tlh(1553) : error C3203: '_com_IIID' : unspecialized class template can't be used as a template argument for template parameter '_IIID', expected a real type
    1>c:\users\jim\documents\visual studio 2005\projects\autoproject\autoproject\debug\excel.tlh(1560) : error C2371: 'PicturePtr' : redefinition; different basic types

    double clicking the error msg jumps one to thingslike this:

    _COM_SMARTPTR_TYPEDEF(Rectangle, __uuidof(Rectangle));

    i took the opportunity to respond to the standard survey one sees when one links to kb articles to state that i had the same complaints i had with the prior article: it did compile. i stated what i had stated previously to the question on how to make the info better:

    verify the problem
    fix the problem
    update the (and i always gag on this) "documentation"

    i included my name and phone # - i do not expect a response. however, i will be interested in how quickly it takes ms to figure out the most effective way to alter their product code so that this prior article will be brought up to
    standard by increasing the number of compiler violations to that of the new article. perhaps they upgraded the erroneous, yes ERRONEOUS (i use the term "erroneous"often in relation to code that does not work), documentation specialist position at some point in the past but that is just a guess. all i know is that the older article doesn't produce as many
    compiler errors - what's up with that?

    i am conflicted as to what to do next. should i surf the web for links to other individuals who posted those compiler messages and got no answers or
    should i go further through prior articles to find more articles with code that does not compile. the reason i am conflicted is because if i ever found a piece of code from an ms kb article that worked and that become public knowledge then some ms guy who never got the memo about publishing ERRONEOUS code might be fired (he may even have a wife and kids). worse, bill gates might have a hit squad sent after me since i screwed up and gave my real email address and phone number. what do you think? should i leave the country?
    Last edited by jim enright; February 3rd, 2011 at 09:58 PM. Reason: typos

  11. #11
    Join Date
    Oct 1999
    Location
    ks
    Posts
    523

    Re: excel in/on dialog box

    i changed the project settings to old syntax for CRL as suggested occasionally by some articles. everybody relax - compiler errors still abound.

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