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);
            }
        }


  • 相关阅读:
    Wintellect的Power Collections库
    rabbitMQ的几种工作模式
    解决死锁问题
    项目#editormd 的使用
    spring cloud篇#1
    科学#老鼠和毒药
    #杂记#实现一个简单的tomcat
    #栈#leetcode856.括号的分数
    #栈#单调栈#leetCode94.验证栈序列
    #树#遍历#LeetCode37.序列化二叉树
  • 原文地址:https://www.cnblogs.com/end/p/1757875.html
Copyright © 2011-2022 走看看