---
parser: v2
author_name: Ramakrishnan Raghuraman
author_profile: https://github.com/r3ksk
auto_validation: true
time: 20
tags: [ tutorial>beginner, software-product>sap-business-technology-platform, tutorial>free-tier]
primary_tag: software-product>sap-build-process-automation
slug: spa-integrate-excel-outlook-automations
canonical_url: https://developers.sap.com/tutorials/spa-integrate-excel-outlook-automations
---

# Integrate Excel and Outlook SDK Based Automations To A Single Project
<!-- description --> In this tutorial, you will customize the Excel and Outlook SDK based projects, so that they can be integrated together as a single business process.

## Prerequisites
- Complete the tutorial: [Extend Outlook SDK based automation](spa-extend-outlook-automation)
- Complete the tutorial: [Build Your First Automation Using Excel SDK of SAP Build Process Automation](spa-create-excel-automation)

## You will learn
  - How one automation in a project can be embedded into another automation project
  - How one automation can call another automation,
  - How to pass values from one automation to another
  - How you can build an integrated business process using SAP Build Process Automation

## Intro
SAP Build Process Automation has native integration to several Microsoft Office products including Outlook, Excel SDK. In this tutorial, you will integrate the automations to a single business process. Create a new automation that includes both the Outlook and Excel automations. Use a combination of environment variables and input/output variables to pass information across the project and in this way, processing will be dynamic and can work for any email or Excel file.

---

### Customize Outlook automation


1. In your **Outlook Sample** project, add `baseFolderPath` as an environment variable.
   ![Create Base Folder as Environment Variable](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/01-CreateEnvironmentVariable.png)

2. Use this new path in **Save All Mail Attachments**.
   ![Use the environment variable in Save Mail Attachments](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/02-SaveAsMailAttachmentNewFilePath.png)

3. To reuse this automation, release the **Editable** project. You can do so in two ways.
    - Either you can do so from Lobby by choosing **(...)**
    - From within the project you can do so by clicking the button **Release**

    ![Release Automation Project from SPA Lobby](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/03-ReleasefromSPALobby.png)

4. Another way to release the project.
   ![Release Project from within Automation Project](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/04-ReleaseFromWithinTheProject.png)

5. At release time, it will ask you to specify a version number, you can accept the default suggestion.
   ![Release Project Dialog](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/05-ReleaseVersionDialog.png)

6. Notice the name change from Editable to (version number) Released.
   ![Change in Release status](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/06-ChangeinReleaseStatus.png)



### Customize Excel automation


1. In your Excel project, add **Get Folder Collection** to the `baseFolderPath` environment variable. This step will return all the sub folder names within a given folder. In this case, it will give each timestamp based folders fetched from each email from the Outlook. Rename the output parameter to `folderList`.
  ![Get Folder Collection](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/07-GetFolderCollection.png)

2. You can see the folder name by using a **Log Message**.
  ![Log result of get folder collection](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/08-LogGetFolderCollectionsResult.png)

3. Loop through each folder. For this will add **For Each** loop to the flow.
  ![Add First For Each on Folder Collection Result](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/09-AddForEach.png)

4. Add all the required steps into the folder. The idea is on each file, a certain set of actions needs to be performed.
  ![Move Excel actions inside the loop](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/10-MoveExcelActionsInsideForEachLoop.png)

5. Within each index of **For Each**, fetch list of Excel files in each folder. For this, add **Get File Collection** to the loop.
  ![Add Get File within a folder](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/11-AddGetFIleCollection.png)

6. The value for **Get File Collection** is as given in the image.
  ![Log output of Get File List Collection](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/12-GetFileListValue.png)

7. Add one more **For Each** to loop through each Excel file in that sub folder. Here to distinguish both the loop variables, you can rename it appropriately. Also include the required Excel actions within this sub **For Each** loop.
  ![Add a second ForEach](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/13-AddSecondForEach.png)

8. First create a string variable and assign the loop variable's full path to the Excel file.
  ![Add a File Path Variable](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/14-AddFilePathVariable.png)

9. Adjust the **Get File Name** to take the output variable.
  ![get the file name based on these changes](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/15-GetFileName.png)

10. This tutorial uses hard coded ranges in **Filter Range**. When you generalize the logic to your needs, you may want to calculate this at run time. For example, add `Get UsedRange Row` and Get `UsedRange Column` activities to find out the start and end cell values.
![Amend Filter Range with Dynamic Calculations](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/16-AddStarRangeStarActivities.png)

11. Now use a **Custom script** activity to calculate complete range.
    ![Add a custom script to calculate range of Excel](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/17-AddCustomScript.png)

   ```JavaScript
   var startColumn = 1;
   var startCell = String.fromCharCode(startColumn + 64) + startColumn;
   var endCell = String.fromCharCode(columnRange + 64) + rowRange;
   return startCell + ":" + endCell;
   ```

12. Just for demonstration purpose, filter against the first column and look for cell values containing a.
  ![Apply Filter Range on First column](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/18-FilterRangeDynamically.png)

13. Use similar approach to find out range of values after filtering to be used with **Copy Range**.
  ![Similarly use dynamic calculations on Copy Range](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/19-DynamicRangeCalculation.png)

14. Append **"\_new"** to the new CSV file name in **Save As Workbook**.
  ![Use the loop variable for Save as Workbook](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/20-SaveAsWorkbookPath.png)

15. Like the Outlook sample, you need to release the package and publish to the library. You can do so either from the SAP Build Lobby or from within the project.


### Create an integrated automation project


1. Create a brand new Automation project **Main Automation**.
  ![Create a new Automation Project](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/21-CreateANewProject.png)

2. Include both Excel and Outlook projects as dependency. Here you will add Excel Project. Similarly you have to add Outlook based project.
  ![Add Excel and Outlook projects as dependency](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/22-AddExcelSampleAsDependency.png)

3. This is the result after adding both project's packages as dependency.
  ![final dependent projects added](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/23-DependentProjectsAdded.png)

4. Call this new project as **Main Automation** project.
  ![project creation](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/24-NewAutomationCreation.png)

5. Add automations from both Outlook sample and Excel sample projects to the flow.
   ![add 2 automations to the flow](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/25-AddAutoamtions2TheMain.png)

    > Don't be confused with the name. There are Package/Project Name(s) and Automation name(s). In this step, you will be using automations

6. Save and test the project.

7. At the end, after this tutorial is tested, the below source data was used.
  ![Source Excel Data](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/26-OriginalExcelData.png)

8. After the automaton is executed, it has filtered the data (Town starting with a), hidden a column (Column F with title `storey_range`) and resultant Excel will look like this:
  ![Final Excel Data](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/27-AfterAutomationProcessing.png)

### Learn Microsoft Office Best Practices (Optional)

> To learn more about Excel and Outlook SDKs of SAP Build Process Automation, refer to the samples available in the store.

To retrieve these samples, please follow these steps:
    
1. From the SAP Build Lobby, navigate to Store.
   
2. Search for the sample project: **Excel Best Practices**.
   
3. Choose **Add** > **Create from Template** to retrieve the sample and save it as a new project in your lobby.

    ![Store](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/excelSearch.png)

4. Choose **Create**.

    ![Create](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/createExcel.png)

    Your project gets created in editable version. You may release and deploy it and run the project.
    
5. Navigate back to the lobby by clicking on the SAP logo.
  
    ![Project](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/proj.png)

    You can see your project is available in the lobby.
  
    ![Lobby](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/lobbyExcel.png)

6. Similarly, you can add **Outlook Best Practices(calendar)** and **Outlook Best Practices(mail)** from the Store to your lobby.
    ![Lobby](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-integrate-excel-outlook-automations/outlookBoth.png)

---
