Below is a snippet of code that uses the Before Delete event of an Active Constituent record to record constituent data to an excel file before it is deleted.



Private Sub RaisersEdgeRecord_BeforeDelete(oRecord As Object, bcancel As Boolean)

   

 

   Dim oconstituent As CRecord

   Set oconstituent = oRecord

   

   Dim oExcel As Excel.Application

   Set oExcel = CreateObject("Excel.Application")



   Dim lFindRow As Long



  'The following section opens up an Excel file and then stores the fields that we chosen.

   With oExcel

       .Workbooks.Open FileName:="c:\delete.xls"

       lFindRow = .Cells(1, 2) + 4

       .Cells(lFindRow, 1) = lFindRow - 3

       .Cells(lFindRow, 2) = oconstituent.Fields(RECORDS_fld_FULL_NAME)

       .Cells(lFindRow, 3) = oconstituent.Fields(RECORDS_fld_IMPORT_ID)

       .Cells(lFindRow, 4) = Date

       .Cells(lFindRow, 5) = Time

       lFindRow = lFindRow - 3

       .Cells(1, 2) = lFindRow



       .ActiveWorkbook.Save

       .ActiveWorkbook.Close

       .Quit

   End With



   Set oExcel = Nothing

   Set oconstituent = Nothing



End Sub

Disclaimer: We provide programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes you are familiar with Microsoft Visual Basic and the tools used to create and debug procedures. Our Customer Support can help explain the functionality of a particular procedure, but we will not modify, or assist you with modifying, these examples to provide additional functionality. If you are interested in learning more about the VBA and API modules, contact your account manager.