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:
For installation instructions, refer to 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 (in this case, Salesforce) and the ODBC driver that is required to connect to it (in this case, 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 Data Source Administrator, which is included with Windows.
There are two versions of ODBC Data Source Administrator. The version of ODBC Data Source 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 Data Source Administrator. To do this, in the Windows Run dialog box, enter:
%windir%\system32\odbcad32.exe
If you have the 32-bit version of Excel, you need to run 32-bit version of ODBC Data Source Administrator. To do this, in the Windows Run dialog box, enter:
%windir%\syswow64\odbcad32.exe
Use ODBC Data Source Administrator to create your Salesforce ODBC driver data source:
–Or–
Easysoft ODBC-Salesforce Driver
, and then choose Finish.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 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. Choose 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.
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, you'll be prompted to install it if you choose New Database Query. 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 or Excel. Microsoft Query is located under Office Tools.
When you've installed Microsoft Query, repeat step 1.
WHERE
clause), and then click Next.ORDER BY
clause), 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 anf 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.
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 |
PRODUCTS
.
This creates a named range called PRODUCTS
, which contains the products to be inserted into Salesforce.
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
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 choose 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 with the name of your ODBC data source. con.Open "Salesforce" 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