Click here to Skip to main content
15,867,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
import "C:\\Program Files (x86)\\Common Files\\microsoft shared\\OFFICE14\\MSO.DLL" \
rename( "RGB", "MSORGB" )

using namespace Office;

#import "C:\\Program Files (x86)\\Common Files\\microsoft shared\\VBA\\VBA6\\VBE6EXT.OLB"

using namespace VBIDE;

#import "C:\Program Files (x86)\Microsoft Office\Office14\\EXCEL.EXE" \
rename( "DialogBox", "ExcelDialogBox" ) \
rename( "RGB", "ExcelRGB" ) \
rename( "CopyFile", "ExcelCopyFile" ) \
rename( "ReplaceText", "ExcelReplaceText" ) \
exclude( "IFont", "IPicture" ) no_dual_interfaces

What I have tried:

Intellisense in Visual C++ 12 is not liking using namespace Office/VBIDE and even though I have ensure that the Path for VBE6EXT.OLB and EXCEL.EXE is correct, Intellisense is prompting Error:: cannot open source file ...... I am trying to Automate EXCEL 2010 using Visual C++. I do not know if this question has been asked on MSDN. Can the code on this link be adapted to dynamically import an entire vector>
http://www.technical-recipes.com/2012/how-to-interface-with-excel-in-c/
Thanks for your help.
Posted
Updated 25-Apr-16 3:43am
Comments
RedDk 21-Mar-16 16:33pm    
CIO:

https://code.msdn.microsoft.com/office/CppAutomateExcel-be36992e
leon de boer 25-Apr-16 22:47pm    
That won't work its old using the old GUID import and is specific to Excel 2007 on VS2010

1 solution

Ok let me first answer your question and secondly suggest a better alternative

You missed a line ===> rename_namespace("Excel")

#import "C:\\Program Files (x86)\\Common Files\\microsoft shared\\OFFICE14\\MSO.DLL" \
    rename( "RGB", "MSORGB" ) \
	exclude( "DocumentProperties")

using namespace Office;

#import "C:\\Program Files (x86)\\Common Files\\Microsoft Shared\\VBA\\VBA6\\VBE6EXT.OLB"

using namespace VBIDE;

#import "C:\\Program Files (x86)\\Microsoft Office\\OFFICE14\\EXCEL.EXE" \
    rename_namespace("Excel") \
    rename("DialogBox", "DialogBoxXL") \
    rename("RGB", "RBGXL") \
    rename("DocumentProperties", "DocumentPropertiesXL") \
    rename("ReplaceText", "ReplaceTextXL") \
    rename("CopyFile", "CopyFileXL") \
	exclude( "IFont", "IPicture") \
    no_dual_interfaces

using namespace std;


The simpler alternative is to connect an ODBC data source from control panel to the excel file and access it from the ODBC interface.
If you want to look at that download the free personal edition of SqlDbx, connect an excel file as an ODBC data source from control panel and connect to it on SqlDbx. Play and edit the SQL file to your hearts content.

There is a multitude of ODBC code available which will let you do the same things.
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900