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.
The Salesforce.com ODBC Driver is available to download from the Easysoft web site:
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:
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.)
|User Name||The name of your Salesforce.com user. For example, email@example.com.|
|Password||The password for your Salesforce.com user.|
|Token||The 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
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.
You can now connect Excel to Salesforce.com.
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.
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.
WHEREclause), and then click Next.
ORDER BYclause), and then click Next.
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]
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.
|Easysoft ODBC-Salesforce Driver||ODBC Driver for Salesforce.com, Force.com, Database.com||Easysoft Data Access|
|Easysoft ODBC-SQL Server Driver||ODBC Driver for SQL Server, SQL Azure||Easysoft Data Access|
This creates a named range called PRODUCTS, which contains the products to be inserted into Salesforce.com.
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
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.
Public Sub AddRecords() Dim con As New ADODB.Connection Dim cmd As New ADODB.Command Dim rngRow As Range Dim rngCell As Range Dim i As Integer 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" With cmd .ActiveConnection = con .CommandType = adCmdText End With For Each rngRow In Worksheets("Sheet1").Range("Products").Rows For Each rngCell In rngRow.Cells With cmd .Parameters.Append .CreateParameter(Type:=adWChar, Size:=Len(rngCell.Value), Value:=rngCell.Value) End With Next With cmd .CommandText = strcSQL .Execute For i = 0 To .Parameters.Count - 1 .Parameters.Delete i Next End With Next con.Close Set con = Nothing Set cmd = Nothing End Sub
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.