Problems Disabling Various Functions Word

Add-in Express™ Support Service
That's what is more important than anything else

Problems Disabling Various Functions Word
 
Mark Williams




Posts: 21
Joined: 2020-06-08
There are quite a few Word function I would like to disable/hide from users. I have managed to deal with most of these using RibbonTab, RibbonCommands and BackStageView.

I am stuck on a couple of functions. I am not sure if I am approaching them in the wring way. List is below with notes as to how I have tried to approach them.

Macros
I want to disable the running of macros. I have hidden the macro group on the View tab, which will stop a number of users, but I am having problems disabling the actual functionality. There are a no of controls involved:

MacroPlay - which is a stand alone function that opens a list of macros.
PlayMacro -this is the View Macros menu item that appears on the Macros split button on the View tab
MenuMacros - this is the splitbutton that appears on the Macros Group View tab

I have added an adxRibbonCommand for each of these items, but it fails to disable any of them. If this is not possible do you know of any other way to disable the playing of macros?

Transform
DigitalPrint - I cannot disable this via an adxRibbonCommand although I can hide it on the backstage view. The user can however add it as a button via customise ribbon so ideally would wish to disable the function.

SaveAs
FileSaveAsMenu - this is a split button, but the adxRibbonCommand doesn't have a controlType for this so I tried all possible options for this and none of them work

Export
This is on the backstage. I can't find it id. I've tried to identify it via the excel list of commands and also via the File tab in Customise Ribbon, but I can't find it. Ideally I would like to hide it on the File Tab. If not, when you click on it, it gives an option to create a pdf or xps and also to Change File Type. The latter is problematic for me, if I could disable just that option that would work (but I can't find its id either).

The following are all buttons that I cannot get to disable via adxRibbonCommands and not sure whatever approach to take
FileSaveAsWordDotX
FileSaveAsWordDocx
FileSaveAsWord97_2003
VisualBasic
FileSaveAsWebPage
FileNew
FileNewDialogClassic
UpgradeDocument
Posted 12 Aug, 2020 08:49:26 Top
Andrei Smolin


Add-in Express team


Posts: 17361
Joined: 2006-05-11
Hello Mark,

Of all restrictive solutions I saw this is the most detailed one.

The Office object model doesn't provide a way to prevent a macro from running. In fact, Excel and Word were developed with macros as integral part of user experience. In theory you could delete all macros using the VBIDE object model. This requires that the following check box is selected: Developer tab | Macro Security | Trust access to the VBA project model. Another way is you could select the "Disable all macros without notifications" option on the same page. I suppose however this influences all workbooks and this looks inacceptable.

In the Ribbon UI you can hide all controls in a given Ribbon by specifying that Ribbon in the StartFromScratch property of the add-in module. Don't know if the corresponding Ribbon command gets actually disabled for a Ribbon control hidden in this way.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 13 Aug, 2020 02:52:41 Top
Mark Williams




Posts: 21
Joined: 2020-06-08
Andrei Smolin writes:
Of all restrictive solutions I saw this is the most detailed one.


I'm an obsessive compulsive control freak. What can I say?

I was trying to disable any functions that would allow the opening of a document in the same word application as the one my app has created and to prevent the user saving the document created by that app.

I have tested the various functions that allow this to happen and I can see that I can deal with this with two simple techniques:
1. Your little trick for opening and closing a document when creating the wordapp also works for new windows/docs which the user requests to be opened via my instance of the wordapp. Wasn't expecting that.
2. As for save requests I can just deal with these by cancelling them in the DocumentBeforeSave event. I want to allow the user to be able to save in pdf/xps, but I can't see how the format can be ascertained in the before save event. However, I will just add my own function to allow for that.
Posted 13 Aug, 2020 03:52:44 Top