zoukankan      html  css  js  c++  java
  • How to make Office VBA code interact with a VSTO applicationlevel addin

    代码
    public partial class ThisAddIn
    {
        
    protected override object RequestComAddInAutomationService()
        {
            
    return new AutomationServiceFactory();
        }        
    }
        [ComVisible(
    true), ClassInterface(ClassInterfaceType.None)]
        
    public class AutomationServiceFactory:IAutomationServiceFactory
        {
            
    /*
            Sub RaiseAddinEvent()
                Dim service
                Dim vbaEvent
                
                Set service = Application.COMAddIns.Item("ExcelAddInStudy").Object
                Set vbaEvent = service.Create("")
                vbaEvent.Raise ("Thanks")
            End Sub
             * 
    */
            
    public object Create(string objectId)
            {
                
    return new VbaEvents();
            }
        }
        [ComVisible(
    true), InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
        
    public interface IVbaEvents
        {
            
    void Raise(string @event);
            
    void UpdateVertical(string @event);
            
    void ApproveVertical(string @event);
            
    void SaveQuota(int @event);
        }
        [ComVisible(
    true), ClassInterface(ClassInterfaceType.None)]
        
    public class VbaEvents : IVbaEvents
        {
            
            
    public void Raise(string @event)
            {
                MessageBox.Show(@event);
            }

            
    public void UpdateVertical(string @event)
            {
                VerticalMappingToolView vt 
    = new VerticalMappingToolView();
                vt.UpdateVertical();
            }
            
    public void ApproveVertical(string @event)
            {
                 VerticalMappingToolView vt 
    = new VerticalMappingToolView();
                 vt.ApproveVertical();
            }


            
    public void SaveQuota(int @event)
            {
                QuotaSave.Save(@event);
            }
        }


  • 相关阅读:
    ansible变量
    nginx连接php测试
    redis发布订阅
    堡垒机实例以及数据库操作
    nginx简介,使用
    protobuf
    go NSQ
    go mod
    GIT版本管理工具教程
    linux命令查询网站
  • 原文地址:https://www.cnblogs.com/end/p/1757875.html
Copyright © 2011-2022 走看看