Sample Code for Writing Macros

Note:

All programming samples are for illustration only, and are provided without warranty, either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability and/or fitness for a particular purpose.

This example shows how to use the calls provided with FinancialForce XL Plus. To use the code in Excel, create a button, then copy and paste the example code. The steps are:

  1. Install FinancialForce XL Plus and open Microsoft Excel.
  2. Enable the Developer tab in Excel.
  3. From the Developer tab, use the Insert form control option to define your button, and select the location on the worksheet.
  4. Type in a name for the button and then click New to open the definition window. Copy and paste the code below in to the Assign Macro window.
  5. Click New to create the button.

Refer to the Microsoft help for instructions if needed.

Example: Refresh a report using its ID

FinancialForce Reports

To refresh a report by using its ID, create a button and copy this code snippet:

Sub Button1_Click()
'In the below line the ReportId is the ID of the report that we need to specify to refresh the report   
    Dim ReportId As String: ReportId = "ReportId"
    Set automationObject = GetAutomationObject 
    Call automationObject.ImportFinancialForceReportById(ReportId)
End Sub

'Function to get the automation object
Private Function GetAutomationObject() As Object
    Dim addIn As COMAddIn
    Dim automationObject As Object
    Set addIn = Application.COMAddIns("FinancialForce.FinancialForceXL")
    Set GetAutomationObject = addIn.Object
End Function

Salesforce Reports

To refresh a report by using its ID, create a button and copy this code snippet:

Sub Button1_Click()
'In the below line the ReportId is the ID of the report that we need to specify to refresh the report   
    Dim ReportId As String: ReportId = "ReportId"
    Set automationObject = GetAutomationObject 
    Call automationObject.ImportSalesforceReportById(ReportId)
End Sub

'Function to get the automation object
Private Function GetAutomationObject() As Object
    Dim addIn As COMAddIn
    Dim automationObject As Object
    Set addIn = Application.COMAddIns("FinancialForce.FinancialForceXL")
    Set GetAutomationObject = addIn.Object
End Function