Excel自动化和ExecuteExcel4Macro,c ++ [英] Excel automation and ExecuteExcel4Macro, c++

查看:283
本文介绍了Excel自动化和ExecuteExcel4Macro,c ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。

我遇到以下问题。 我在我的应用程序中显示excel网格,我需要隐藏excel2007功能区。对于excel2003-我使用ToolBar.SetVisible(FALSE)来隐藏excel工具栏,它工作正常。

I have the following problem.  I show excel grid in my application and I need to hide excel2007 ribbon. For excel2003- I use ToolBar.SetVisible(FALSE) to hide excel toolbar and it works fine.

据我所知隐藏功能区的方法是Excel宏"SHOW.TOOLBAR(\ " \" Ribbon\" \",FALSE)" ;.如果我从excel本身运行它,这个宏工作正常。

As I understand the way to hide ribbon is Excel macro "SHOW.TOOLBAR(\"\"Ribbon\"\",False)". This macro works fine if I run it from excel itself.

要从我的C ++代码运行它,我使用  ExecuteExcel4Macro函数:

To run this from my C++ code I use ExecuteExcel4Macro function:

_Application ExApp;

_Application ExApp;

ExApp.ExecuteExcel4Macro(

ExApp.ExecuteExcel4Macro(

" SHOW.TOOLBAR(\" \" Ribbon \" \",False) " );

它根本不起作用(但也不显示错误)。

同时
ExApp.SetDisplayFormulaBar(FALSE);或者ExApp.Run("MyMacro",......)工作正常。

At the same time ExApp.SetDisplayFormulaBar(FALSE); or ExApp.Run("MyMacro", ....) works fine.

 

ExecuteExcel4Macro的定义通常  VC生成:

Definition of ExecuteExcel4Macro is usual VC generated:


VARIANT _Application::ExecuteExcel4Macro(LPCTSTR String)
{
	VARIANT result;
	static BYTE parms[] =
		VTS_BSTR;
	InvokeHelper(0x15e, DISPATCH_METHOD, VT_VARIANT, (void*)&result, parms,
		String);
	return result;
}

推荐答案

你好,

谢谢用于联系Excel论坛。请在ExecuteExcel4Macro方法中使用String参数,如下所示,

Thanks for contacting Excel forum. Please use String argument in ExecuteExcel4Macro method like this,

ExApp.ExecuteExcel4Macro(" SHOW.TOOLBAR(\" Ribbon \","False)");

ExApp.ExecuteExcel4Macro("SHOW.TOOLBAR(\"Ribbon\",False)");

如果这对您没有帮助,请随时回来。祝你度过愉快的一天。

If this does not help you, just feel free to come back. Have a nice day.

致以最诚挚的问候,b
Bessie

Best regards,
Bessie


这篇关于Excel自动化和ExecuteExcel4Macro,c ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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