Basic Excel Problem


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Basic Excel Problem

Hybrid View

  1. #1
    Join Date
    Apr 2009
    Posts
    13

    Smile Basic Excel Problem

    Hello all,

    I am working on a project and want to load excel libraries into C++ so that I can read/write data into cells.
    Code:
    #include <iostream>
    #include <cmath>
    
    // Office XP Objects (2003)
    #import "C:\Program Files\Common Files\Microsoft Shared\OFFICE12\mso.dll"\
    	rename("DocumentProperties", "DocumentPropertiesXL")\
    	rename("RGB", "RBGXL")
    
    //Microsoft VBA objects
    #import "C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB"
    
    //Excel Application objects
    #import "C:\Program Files\Microsoft Office\Office\excel.exe" \
    	rename("DialogBox", "DialogBoxXL")\
    	rename("RGB", "RBGXL")\
    	rename("DocumentProperties", "DocumentPropertiesXL")\
    	rename("ReplaceText", "ReplaceTextXL")\
    	rename("CopyFile", "CopyFileXL")\
    	exclude("IFont", "IPicture") no_dual_interfaces
    
    using namespace std;
    When I wrote the above code, I am getting an error

    Code:
    fatal error C1083: Cannot open type library file: 'c:\program files\microsoft office\office\excel.exe': Error loading type library/DLL.
    Can someone please tell me what I am missing here inorder to run the code.

    Thanks In Advance.

  2. #2
    Join Date
    Sep 2009
    Posts
    3
    I think you can add the header:

    #include "Excel9.h"

  3. #3
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  4. #4
    Join Date
    Apr 2009
    Posts
    13
    Hi,

    After struggling a little bit, now I am able to write 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

  5. #5
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,666
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  6. #6
    Join Date
    Apr 2008
    Posts
    17
    Everything is in MSDN
    (and Win32 grp http://tinyurl.com/cmhb5g for Win32 COM)
    Dozens of samples in C and C++ (official code, from MS...)

Similar Threads

  1. Problem on reading Excel file by ADO
    By mkmkmk2 in forum VB Classic
    Replies: 5
    Last Post: 02-17-2009, 04:48 AM
  2. Replies: 2
    Last Post: 09-13-2006, 09:15 PM
  3. Will VB.NET be more stable than VB6?
    By Jason in forum .NET
    Replies: 125
    Last Post: 10-05-2002, 04:34 PM
  4. The basic problem is...
    By George in forum VB Classic
    Replies: 0
    Last Post: 10-24-2001, 06:54 AM
  5. Re: Editorial by Russell Jones/Attack on Gosub
    By Dan Barclay in forum .NET
    Replies: 90
    Last Post: 03-09-2001, 07:04 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center