安装 vs.net2005 

  安装 microsoft visual studio 2005 tools for office runtime
                    microsoft visual studio 2005 tools for office runtime language pack

  安装office2003 sp2   +  .net 支持

  创建一个项目

  .net 中新建一个 其他项目类型 -〉 扩展性 -〉 共享的外接程序

  项目中引用

extensibility

Microsoft Office 11.0 Object Library

COM:Microsoft Excel 11.0 Object Library

  程序中导入

  imports Extensibility
        Imports System.Runtime.InteropServices
        Imports Microsoft.Office.Interop

  excel对象模型介绍

  application--> workbook-->worksheet->cell

        例子代码:(只要注意其中的四行即可)

imports 
   Extensibility
 
  Imports 
   System.Runtime.InteropServices
 
  Imports 
   Microsoft.Office.Interop

 
  Read me for Add-in installation and setup information. 
  #Region " Read me for Add-in installation and setup information. "
' When run, the Add-in wizard prepared the registry for the Add-in.
' At a later time, if the Add-in becomes unavailable for reasons such as:
'   1) You moved this project to a computer other than which is was originally created on.
'   2) You chose 'Yes' when presented with a message asking if you wish to remove the Add-in.
'   3) Registry corruption.
' you will need to re-register the Add-in by building the $SAFEOBJNAME$Setup project, 
' right click the project in the Solution Explorer, then choose install.
#End Region 
  

 
  < 
  GuidAttribute( 
  " 
  010A79D2-C4FB-4FF0-8580-2A842A4A8601 
  " 
  ), ProgIdAttribute( 
  " 
  myExcel.Connect 
  " 
  ) 
  > 
   _
 
  Public 
    
  Class Connect 
  Class Connect
    
    Implements Extensibility.IDTExtensibility2

    Dim app As Excel.Application    '注意这行
        Dim addInInstance as object
    
    Public Sub OnBeginShutdown()Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdown

    End Sub
    
    Public Sub OnAddInsUpdate()Sub OnAddInsUpdate(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnAddInsUpdate

    End Sub
    
    Public Sub OnStartupComplete()Sub OnStartupComplete(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnStartupComplete

    End Sub
    
    Public Sub OnDisconnection()Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnDisconnection

    End Sub
    
    Public Sub OnConnection()Sub OnConnection(ByVal application As Object, ByVal connectMode As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnConnection
        app = CType(application, Excel.Application)
      
        addInInstance = addInInst
      ''请注意下面的代码
         Dim wb As Excel.Workbook
        If app.Workbooks.Count > 0 Then
            wb = app.ActiveWorkbook
        Else
            wb = app.Workbooks.Add
        End If
        Dim ws As Excel.Worksheet
        If wb.Worksheets.Count > 0 Then
            ws = wb.ActiveSheet
        Else
            ws = wb.Worksheets.Add
        End If
     ws.Cells(8, 6).value = "I am northsnow "

    End Sub


End Class

  生成 解决方案,安装 

  启动excel 既看到效果