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


  • 相关阅读:
    sizeof注意
    如何获取存储过程的返回值和输出值
    OA、ERP、SRM、PLM、CAPP、MES、LIMS、CRM
    js1号脚本
    Python各类常用库整理
    Html设计器
    python从入门到放弃之图像处理
    C# Web API操作Sqlite数据库
    C# Naudio 从麦克风输入到声卡输出 录音 放音功能
    WPF/MVVM模式入门教程(二):实现INotifyPropertyChanged接口
  • 原文地址:https://www.cnblogs.com/end/p/1757875.html
Copyright © 2011-2022 走看看