Easysoft ODBC-Salesforce Driver

How do I connect Microsoft Excel to Salesforce?

Article:
01047
Last Reviewed:
31st January 2024
Revision:
2

New! The Salesforce ODBC driver now includes two ODBC drivers one which supports SQL and one which supports SOQL. This article is for the SQL version of the driver (Easysoft Salesforce ODBC Driver). For the SOQL version of the driver please refer to this blog.

Use the Salesforce ODBC Driver to connect Microsoft Excel to Salesforce and:

The Salesforce ODBC Driver is available to download from the Easysoft web site:

  1. Download the Windows Salesforce ODBC Driver.
  2. Install and license the Salesforce ODBC Driver on the machine where Excel is installed.

    For installation instructions, see the Salesforce ODBC Driver documentation.

Before you can use the Salesforce ODBC Driver to connect Excel to Salesforce, you need to configure an ODBC data source. An ODBC data source stores the connection details for the target database (e.g. Salesforce) and the ODBC driver that is required to connect to it (e.g. the Salesforce ODBC driver).

You can configure a User ODBC data source, which is only available to the user who creates it, or a System ODBC data source, which is available to all users on the machine. You configure ODBC data sources in ODBC Administrator, which is included with Windows.

There are two versions of ODBC Administrator. The version of ODBC Administrator that you need to run depends on whether you have a 32-bit or a 64-bit version of Excel. To find out which version of Excel you have, start Excel, and then start Windows Task Manager. In Task Manager, choose the Processes tab. Look for Excel.exe in the list. If this process name is followed by *32, your version of Excel is 32-bit. Otherwise, your version of Excel is 64-bit.

If you have the 64-bit version of Excel, you need to run 64-bit version of ODBC Administrator. To do this, in the Windows Run dialog box, type:

%windir%\system32\odbcad32.exe

If you have the 32-bit version of Excel, you need to run 32-bit version of ODBC Administrator. To do this, in the Windows Run dialog box, type:

%windir%\syswow64\odbcad32.exe

Use ODBC Administrator to create your Salesforce ODBC Driver data source:

  1. Do one of the following:
    • To create a User data source, in the User DSN tab, choose Add.

      –Or–

    • To create a System data source, choose the System DSN tab, and then choose Add.
  2. In the Create New Data Source dialog box, choose Easysoft ODBC-Salesforce Driver, and then choose Finish.
  3. Complete the Easysoft ODBC-Salesforce Driver DSN Setup dialog box:
    Setting Value
    DSN Salesforce
    User Name The name of your Salesforce user. For example, myuser@mydomain.com.
    Password The password for your Salesforce user.
    Token The security token for your Salesforce user, if required.

    To find out whether you need to supply a security token, choose the Test button. If the connection attempt fails with an error which contains LOGIN_MUST_USE_SECURITY_TOKEN, you need to supply one.

    Salesforce emails the security token to the email address associated with your Salesforce user account. If you have not received a security token, you can regenerate it. Salesforce will then email the new security token to you. To regenerate your security token, log in to Salesforce and then choose Setup from the user menu. Search for "security token" in the Quick Find box. Click Reset Security Token in the Reset Security Token page. When you receive the token in your email client, copy it and then paste it into the Token field.

  4. Use the Test button to verify that you can successfully connect to Salesforce.

You can now connect Excel to Salesforce.

Example: How to return data from Salesforce to Microsoft Excel by using the Data Connection Wizard

  1. Do one of the following:
    • For Excel 2007 and later, on the Data tab, in the From Other Sources group, choose From Data Connection Wizard.
    • For Excel 2003 and earlier, on the Data menu, choose Import External Data, and then choose Import Data.
  2. For Excel 2003 and earlier, in the Select Data Source dialog box, choose New Source. For Excel 2007 and later, skip this step.
  3. In the Data Connection Wizard, choose ODBC DSN from the list, and then choose Next.
  4. Choose your Salesforce ODBC driver data source from the list, and then choose Next.
  5. Choose the table that contains the data you want to retrieve, and then choose Next.
  6. Name and describe your new Data Connection File, and then choose Finish.
  7. In the Select Data Source dialog box, open your new Data Connection File.
  8. In the Import Data Dialog box choose the destination cell and worksheet for the data, and then choose OK to return your Salesforce data to Excel.

Example: How to return data from Salesforce to Microsoft Excel by using Microsoft Query

  1. Do one of the following:
    • For Excel 2007 and later, on the Data tab, in the From Other Sources group, choose From Microsoft Query.
    • For Excel 2003 and earlier, on the Data menu, choose Import External Data, and then choose New Database Query.

    The New Database Query command uses Microsoft Query to import data. Microsoft Query is an optional feature, which by default is not installed. If you do not have Microsoft Query installed, choosing New Database Query will prompt you to install it. To do this, in Control Panel, choose Programs and Features (or Add or Remove Programs). Choose Microsoft Office (if you installed Excel as part of Office) or Microsoft Excel, and then choose Change. Follow the instructions on screen. Select Choose advanced customization of applications during the Setup wizard if this option is present for your version of Office / Excel. Microsoft Query is located under Office Tools.

    When you have installed Microsoft Query, repeat step 1.

  2. In the Choose Data Source dialog box, choose your Salesforce ODBC driver data source from the list, and then choose OK.
  3. In the Query Wizard, choose the columns that contain the data you want to retrieve, and then click Next.
  4. If you want to return a subset of the data, use the Filter Data screen to filter the results of your query (this is the equivalent of a SQL WHERE clause), and then click Next.
  5. If you want to change the sort order of your data, use the Sort Order screen to sort the results of your query (this is the equivalent of a SQL ORDER BY clause), and then click Next.
  6. Click Finish to return your Salesforce data to Excel.

Note If your are working with Salesforce data in Query by using SQL, enclose Salesforce object names in square brackets if they are reserved words in SQL / ODBC. For example:

select * from [Case]
select * from [User]

Example: How to insert data from Microsoft Excel into Salesforce

This example uses a Visual Basic for Applications (VBA) subroutine to insert products contained in an Excel spreadsheet into the Product2 table in Salesforce.

  1. Create a new Excel spreadsheet.
  2. In the first worksheet, add these sample products:
    Name Description Family
    Easysoft ODBC-Salesforce Driver ODBC Driver for Salesforce, Force.com, Database.com Easysoft Data Access
    Easysoft ODBC-SQL Server Driver ODBC Driver for SQL Server, SQL Azure Easysoft Data Access
  3. Select the sample products (the first cell in your selection should contain "Easysoft ODBC-Salesforce Driver", the last cell should contain "Easysoft Data Access".
  4. In the Name box (located in the top left corner of the worksheet), type PRODUCTS.

    This creates a named range called PRODUCTS, which contains the products to be inserted into Salesforce.

  5. Press ALT+F11 to start the Visual Basic Editor.
  6. In the Visual Basic Editor, in the Project Pane, double-click Sheet1 in the list of Objects.
  7. In the Code Window, add the following VBA code:
    Option Explicit
    
    Public Sub AddRecords()
    
        Dim con             As New ADODB.Connection
        Dim rngRow          As Range
        Dim rngCell         As Range
        Dim strRecord       As String
    
        Const strcSQL       As String = "INSERT INTO PRODUCT2 (Name, Description, Family) VALUES"
    
        ' Replace Salesforce with the name of your ODBC data source.
        con.Open "Salesforce"
    
        For Each rngRow In Worksheets("Sheet1").Range("Products").Rows
            For Each rngCell In rngRow.Cells
                strRecord = strRecord & "'" & rngCell.Value & "'" _
                    & IIf(rngCell.AddressLocal <>  rngRow.Cells(rngRow.Cells.Count).Address, ",", "")
            Next
            con.Execute strcSQL & "(" & strRecord & ")"
            strRecord = ""
        Next
    
        con.Close
        Set con = Nothing
    End Sub
    
  8. On the Run menu, choose Run Sub/UserForm to run the new subroutine.

    If you get the error "User Defined type not defined.", on the Run menu, choose Reset. On the Tools menu, choose References. In the References dialog box, choose Microsoft Active X Data Objects n Library, and then click OK. Run the subroutine again.

Note
Applies To

Knowledge Base Feedback

* Did this content help you?
* Please select one option based on your first choice:

(* Required Fields)