代码
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);
}
}
{
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);
}
}