Easysoft ODBC-Salesforce Driver

How do I connect Microsoft Excel to Salesforce.com?

Article:
01047
Last Reviewed:
9th August 2013
Revision:
2

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

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

  1. Download the Windows Salesforce.com ODBC Driver. (Registration required.)
  2. Install and license the Salesforce.com ODBC Driver on the machine where Excel is installed.

    For installation instructions, see the Salesforce.com ODBC Driver documentation.

Before you can use the Salesforce.com ODBC Driver to connect Excel to Salesforce.com, you need to configure an ODBC data source. An ODBC data source stores the connection details for the target database (e.g. Salesforce.com) and the ODBC driver that is required to connect to it (e.g. the Salesforce.com 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.

64-bit Windows There are two versions of ODBC Administrator on this platform. (If you are not sure whether your version of Windows is 32-bit or 64-bit, follow the instructions in this Microsoft Knowledge Base article to find out.) 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, open Administrative Tools in Control Panel, and then open Data Sources (ODBC). (On Windows Server 2003 and earlier, the Control Panel applet that launches ODBC Administrator is labelled Data Sources. On Windows 8 and later, the Control Panel applet is labelled ODBC Data Sources (64-bit).)

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

32-bit Windows To run ODBC Administrator on 32-bit Windows, open Administrative Tools in Control Panel, and then open Data Sources (ODBC). (On older versions of Windows, the Control Panel applet that launches ODBC Administrator is labelled Data Sources.)

Use ODBC Administrator to create your Salesforce.com 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:
    SettingValue
    DSNSalesforce.com
    User NameThe name of your Salesforce.com user. For example, myuser@mydomain.com.
    PasswordThe password for your Salesforce.com user.
    TokenThe security token for your Salesforce.com 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.com emails the security token to the email address associated with your Salesforce.com user account. If you have not received a security token, you can regenerate it. Salesforce.com will then email the new security token to you. To regenerate your security token, log in to Salesforce.com 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.com.

You can now connect Excel to Salesforce.com.

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

Note To use this method of returning Salesforce.com data to Excel, you need to use version 1.0.12 or later of the Salesforce.com ODBC driver.

  1. Do one of the following:
    • For Excel 2007 and later, on the Data tab, in the From Other Sources group, choose 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.com 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.com data to Excel.

Example: How to return data from Salesforce.com 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.com 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.com 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.com

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

  1. Create a new Excel spreadsheet.
  2. In the first worksheet, add these sample products:
    NameDescriptionFamily
    Easysoft ODBC-Salesforce DriverODBC Driver for Salesforce.com, Force.com, Database.comEasysoft Data Access
    Easysoft ODBC-SQL Server DriverODBC Driver for SQL Server, SQL AzureEasysoft 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.com.

  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.com with the name of your ODBC data source.
        con.Open "Salesforce.com"
    
        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)