使用visual C ++ 2012自动化EXCEL 2010 [英] Automation of EXCEL 2010 using visual C++ 2012

查看:130
本文介绍了使用visual C ++ 2012自动化EXCEL 2010的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

导入C:\\Program Files(x86)\\Common Files \\microsoft shared\\OFFICE14 \\\\ MSO.DLL\

重命名(RGB,MSORGB)



使用命名空间Office;



#import C:\\Program Files(x86)\\Common Files \\ microsoft shared\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ br />
使用命名空间VBIDE;



#importC:\Program Files(x86)\ Microsoft Office \ Office14 \\ EXCEL.EXE\

重命名(DialogBox,ExcelDialogBox)\

重命名(RGB,ExcelRGB)\

重命名(CopyFile,ExcelCopyFile)\

重命名(ReplaceText,ExcelReplaceText)\

exclude(IFont, IPicture)no_dual_interfaces



我尝试过:



智能感知在Visual C ++ 12中不喜欢你唱命名空间Office / VBIDE即使我已经确保VBE6EXT.OLB和EXCEL.EXE的路径是正确的,Intellisense正在提示错误::无法打开源文件......我试图使用Visual自动化EXCEL 2010 C ++。我不知道MSDN上是否有这个问题。可以对此链接上的代码进行调整以动态导入整个向量>

http://www.technical-recipes.com/2012/how-to-interface-with-excel-in-c /

感谢您的帮助。

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.

推荐答案

好的,让我先回答你的问题,然后建议一个更好的选择



您错过了一行===> rename_namespace(Excel)



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;





更简单的替代方法是连接ODBC数据从控制面板到excel文件的源代码并从ODBC接口访问它。

如果你想查看下载SqlDbx的免费个人版,请将excel文件作为ODBC数据源连接到控件面板并在SqlDbx上连接到它。播放和编辑SQL文件到您的内容。



有许多ODBC代码可以让你做同样的事情。



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.


这篇关于使用visual C ++ 2012自动化EXCEL 2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆