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


  • 相关阅读:
    codeforces 940E 思维,dp
    codeforces 469D 2-SAT
    Codeforces 937D dfs
    Educational Codeforces Round 39 (Rated for Div. 2) D dp E 贪心
    Codeforces Round #469 (Div. 2) D 数学递归 E SCC缩点
    Wannafly挑战赛11 D 白兔的字符串 Hash
    Codeforces Round #470 (Div 2) B 数学 C 二分+树状数组 D 字典树
    UVA
    最小生成树(改了两个板子写的)道路建设
    poj1125 基础最短路
  • 原文地址:https://www.cnblogs.com/end/p/1757875.html
Copyright © 2011-2022 走看看