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


  • 相关阅读:
    Qt添加程序图标
    QTcpSocket+QTcpServer+QWebEngineView打造简易聊天室
    Qt聊天室
    QThread+QMutex多线程编程
    Qt设置窗体背景渐变
    Could not resolve host: github.com
    git clone某一分支上的内容
    git基本操作
    C++中的static关键字的总结
    C/C++中static关键字作用总结
  • 原文地址:https://www.cnblogs.com/end/p/1757875.html
Copyright © 2011-2022 走看看