Trap Open even in Word 07

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

Trap Open even in Word 07
 
Alex Maslennikov


Guest


Is there a way to trap open document menu selection event for Word 07. You have "DocumentOpen" event which is fired after document is already opened. I need to be able to hook in right after user clicked "Open" command from the menu before open dialog is displayed.

Thanks!
Posted 17 Nov, 2009 16:38:24 Top
Andrei Smolin


Add-in Express team


Posts: 18793
Joined: 2006-05-11
Hello Alex,

Are you talking about opening a document in Windows Explorer? If yes, then this doesn't relate to developing Office add-ins and we can't help you with this. If no, then please specify how I can open that menu.


Andrei Smolin
Add-in Express Team Leader
Posted 18 Nov, 2009 06:45:54 Top
Alex Maslennikov


Guest


Hi Andrei,

I am talking about opening new Word Document from within Microsoft Word (Office Button -> Open). Once you click that button open file dialog comes up. I need to be able to hook up there before dialog is opened and show a custom dialog. You have events like DocumentBeforeColse and DocumentBeforeSave but not DocumentBeforeOpen. Is there another way to trap that event?

Thanks!
Posted 18 Nov, 2009 09:21:03 Top
Andrei Smolin


Add-in Express team


Posts: 18793
Joined: 2006-05-11
Hi Alex,

Thank you for the explanation. Below is the code of the add-in module that cancels clicking on the Open button in the Ribbon Office menu:

using System;
using System.Runtime.InteropServices;
using System.ComponentModel;

namespace MyAddin327
{
    /// <summary>
    ///   Add-in Express Add-in Module
    /// </summary>
    [GuidAttribute("29FF478C-2A8A-41D8-83A9-A3A2D967C8CC"), ProgId("MyAddin327.AddinModule")]
    public class AddinModule : AddinExpress.MSO.ADXAddinModule
    {
        public AddinModule()
        {
            InitializeComponent();
            // Please add any initialization code to the AddinInitialize event handler
        }

        private AddinExpress.MSO.ADXRibbonCommand adxRibbonCommand1;
 
        #region Component Designer generated code
        /// <summary>
        /// Required by designer
        /// </summary>
        private System.ComponentModel.IContainer components;
 
        /// <summary>
        /// Required by designer support - do not modify
        /// the following method
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            this.adxRibbonCommand1 = new AddinExpress.MSO.ADXRibbonCommand(this.components);
            // 
            // adxRibbonCommand1
            // 
            this.adxRibbonCommand1.Id = "adxRibbonCommand_4649bcedfbe74fdfb9068585ee28ccce";
            this.adxRibbonCommand1.IdMso = "FileOpen";
            this.adxRibbonCommand1.Ribbons = AddinExpress.MSO.ADXRibbons.msrWordDocument;
            this.adxRibbonCommand1.OnAction += new AddinExpress.MSO.ADXRibbonCommand_EventHandler(this.adxRibbonCommand1_OnAction);
            // 
            // AddinModule
            // 
            this.AddinName = "MyAddin327";
            this.SupportedApps = AddinExpress.MSO.ADXOfficeHostApp.ohaWord;

        }
        #endregion
 
        #region Add-in Express automatic code
 
        // Required by Add-in Express - do not modify
        // the methods within this region
 
        public override System.ComponentModel.IContainer GetContainer()
        {
            if (components == null)
                components = new System.ComponentModel.Container();
            return components;
        }
 
        [ComRegisterFunctionAttribute]
        public static void AddinRegister(Type t)
        {
            AddinExpress.MSO.ADXAddinModule.ADXRegister(t);
        }
 
        [ComUnregisterFunctionAttribute]
        public static void AddinUnregister(Type t)
        {
            AddinExpress.MSO.ADXAddinModule.ADXUnregister(t);
        }
 
        public override void UninstallControls()
        {
            base.UninstallControls();
        }

        #endregion

        public Word._Application WordApp
        {
            get
            {
                return (HostApplication as Word._Application);
            }
        }

        private void adxRibbonCommand1_OnAction(object sender, AddinExpress.MSO.IRibbonControl control, bool pressed, AddinExpress.MSO.ADXCancelEventArgs e)
        {
            e.Cancel = true;
        }

    }
}




The "FileOpen" is the ID of that button. The IDs of all built-in Ribbon controls, can be found in the following download: http://www.microsoft.com/downloads/details.aspx?FamilyID=4329d9e9-4d11-46a5-898d-23e4f331e9ae&DisplayLang=en.

HTH


Andrei Smolin
Add-in Express Team Leader
Posted 18 Nov, 2009 09:57:49 Top
Alex Maslennikov


Guest


Thanks a lot!
Posted 18 Nov, 2009 12:49:14 Top