开发者

Calling a VBA Macro with Parameters from Backstage

开发者 https://www.devze.com 2023-02-15 03:12 出处:网络
In this question I was having problems debugging a Macro with Parameters that I want to use in Office 2010 backstage.

In this question I was having problems debugging a Macro with Parameters that I want to use in Office 2010 backstage.

The answer to that question explains why I could not debut the Macro, but I am still having problems with calling the Macro.

The macro is called by clicking a button in a Backstage tab. There are multiple buttons that call the macro, each one calls it with different parameters. An example call is as follows:

 <button id="bb1" label="开发者_StackOverflowMFLLP Portrait" style="large" onAction="NewDocs (Blank, Portrait.dot)" imageMso="FileSaveAsWordDocx" />

Macros are set as Fully enabled in the Trust Center, yet when I click on any button I get the message

The Macro cannot be found or has been disabled in because of your Macro security settings

I can't see any further settings


OnAction has never taken parameters, in any version of Word. The way around it for most people is to assign a tag to the control and then get that tag from the onAction routine, parse as needed.

The tag will be textual, so you'll just need some good parsing logic, like if you had in your tag "2,True,Blue" then you would split the string, the the first part of the array would be some set of integer value, the next would be boolean values and the next could be color or string values".

This is a complete pain in the @#$ - but it is exactly what all of us VBA devs have been doing over the years to pass parameters.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号