back to top

Using the Excel Application Object with SalesLogix

The Excel application object gives you the ability to programmatically create, modify and manipulate Excel spreadsheets.  Use that object with SalesLogix, and you have a powerful tool for exporting SLX data.

This post will outline the basics for creating and populating a new Excel spreadsheet, and will also provide an example of doing so with SalesLogix data.

First of all, we need to instantiate the object:

    Set xlApp = CreateObject(“Excel.Application”)

Afterwards, we need to create a new worksheet, and make the spreadsheet editable by the end user:

    Set xlWb = xlApp.Workbooks.Add
    Set xlWs = xlWb.Worksheets(“Sheet1”)

These next lines make the spreadsheet visible and editable to the end user:
    xlApp.Visible = True
    xlApp.UserControl = True

At this point, populating individual cells in the active worksheet is simple:

    xlWs.Cells(1, 1).Value = “Test”

A value of “Test” is put in position 1, 1 (or A1).  All you really need to do at this point is repeat that last line for whichever cells you want to populate.  As an example, here is code that will generate a list of Contacts for a specific account:

 

Dim objRS, iCount, xlApp, xlWb, xlWs

Set xlApp = CreateObject(“Excel.Application”) 

Set xlWb = xlApp.Workbooks.Add
Set xlWs = xlWb.Worksheets(“Contacts”)

xlApp.Visible = True
xlApp.UserControl = True 

After setting up the Excel object, we are setting up a header row:

xlWs.Rows(cnt).Font.Bold = True
xlWs.Cells(1, 1).Value = “First Name”
xlWs.Cells(1, 2).Value = “Last Name”
xlWs.Cells(1, 3).Value = “Title”
xlWs.Cells(1, 4).Value = “Work Phone”
xlWs.Cells(1, 5).Value = “Type”

Then we create a new recordset containing contact records, and loop through that recordset to populate the new spreadsheet.

Set objRS =Application.CreateObject(“ADODB.RecordSet”)

With objRS

     .Open “select firstname, lastname, title, workphone, type from contact where
accountid = ‘” & Application.BasicFunctions.CurrentAccountID & “‘”, Application.GetNewConnection

     iCount = 2

     While not (.BOF or .EOF)

          xlWs.Cells(iCount, 1).Value = .Fields(“firstname”).Value
          xlWs.Cells(iCount, 2).Value = .Fields(“lastname”).Value
          xlWs.Cells(iCount, 3).Value = .Fields(“title”).Value
          xlWs.Cells(iCount, 4).Value = .Fields(“workphone”).Value
          xlWs.Cells(iCount, 5).Value = .Fields(“type”).Value

          iCount = iCount + 1

          .MoveNext

     Wend

     .Close

End With

Set xlWs = Nothing

Set xlWb = Nothing
Set xlApp = Nothing

Set objRS = Nothing

That’s all there is to it!

There is quite a bit more to the Excel application object that I have not touched on here.  I would suggest reviewing available resources to see what other options are available to you.  A good place to start would be here:  http://msdn.microsoft.com/en-us/library/aa213696(office.11).aspx

Thanks for reading!  [:)]

Contact Customer FX for your CRM project
We let our expertise speak for itself - let us know how our all-star team can help on your CRM project
About the Author
Jason Buss
Jason Buss
Jason is a senior application developer with Customer FX.

1 COMMENT

  1. we have added a excel object in SLX form.

    but CNTL+F to find a item is not working in excel.

    it open the dialogue box but not abel to search any word

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Infor CRM Sync for Exchange: Action Required by August 31, 2026

Using Infor CRM Sync for Exchange with Microsoft 365? Your Exchange administrator must update tenant settings by August 31, 2026 to prevent sync disruption.

[Webinar] What’s Coming Next for Infor CRM SLX and Why v10 Matters

See what’s coming next for Infor CRM SLX, including new marketing workflows, automation improvements, and reasons to consider upgrading to v10.

Disable Caching in Infor CRM SLX Web Client

In the rare case caching is causing issues in the Infor CRM SLX web client, it is possible to disable specific types of caching by making edits using Application Architect, and then deploying.

Exploring AI Options for Infor CRM v10

I've started taking a closer look at the AI capabilities built into Infor CRM v10. Over the next several posts, I'll share what I learn. From the built-in features and supported AI providers to implementation considerations, costs, and practical use cases.

Infor CRM SLX 10.0: Delegate Ownership Changes for “Everyone” Records

Learn how the new EveryoneOwnerAssignment secured action in Infor CRM SLX 10.0 allows designated users to change ownership of Everyone-owned records without requiring Administrator access.

Related Articles

Infor CRM Sync for Exchange: Action Required by August 31, 2026

Using Infor CRM Sync for Exchange with Microsoft 365? Your Exchange administrator must update tenant settings by August 31, 2026 to prevent sync disruption.

[Webinar] What’s Coming Next for Infor CRM SLX and Why v10 Matters

See what’s coming next for Infor CRM SLX, including new marketing workflows, automation improvements, and reasons to consider upgrading to v10.

Disable Caching in Infor CRM SLX Web Client

In the rare case caching is causing issues in the Infor CRM SLX web client, it is possible to disable specific types of caching by making edits using Application Architect, and then deploying.

Exploring AI Options for Infor CRM v10

I've started taking a closer look at the AI capabilities built into Infor CRM v10. Over the next several posts, I'll share what I learn. From the built-in features and supported AI providers to implementation considerations, costs, and practical use cases.

Related Videos