Page 1 of 1

EasyInput Power Automation Desktop Integration

Posted: Fri Mar 04, 2022 1:38 pm
by moderator
Microsoft Power Automate Desktop (part of Office 365 tools) can facilitate automatizing local desktop tasks (e.g retrieve data from excel, or call excel macro).

EasyInput starting from version 4.03 can be easily integrated with MS Power Automate Desktop.
The easiest way to make calling EasyInput script from Power Automate Desktop (PAD) is to prepare an EI workbook with special macro that will be called from Power Automate Desktop. Example of such a macro:

Code: Select all

Public Function MyEIMacro(ByVal iUser As String, ByVal iPass As String, ByVal iScriptID As String, ByVal iRunType As String) As Boolean

  Dim addIn As COMAddIn
  Dim automationObject As Object
  Dim pWorkbook As Workbook
  Dim e_Result As Boolean
  
  On Error GoTo ErrorHandling
  e_Result = False
  Set addIn = Application.COMAddIns("EasyInput")
   ' force add-in start
  addIn.Connect = True
  Set automationObject = addIn.Object
  Set pWorkbook = ActiveWorkbook

 ' prepare and run the first script
  automationObject.API_BCC_EI_SetSAPUser pWorkbook, iUser
  automationObject.API_BCC_EI_SetSAPPass pWorkbook, iPass
  automationObject.API_BCC_EI_ClearResultMessages pWorkbook
  automationObject.API_BCC_EI_ClearLevelOrder pWorkbook
  If iScriptID <> "" Then automationObject.API_BCC_EI_SetScript pWorkbook, iScriptID
  automationObject.API_BCC_EI_SetRunType pWorkbook, iRunType
  If automationObject.API_BCC_EI_RunScript(pWorkbook) = True Then
    e_Result = True
  End If
  
  MyEIMacro = e_Result
  Exit Function
ErrorHandling:
  ' Do nothing
End Function

Public Sub Start(ByVal iUser As String, ByVal iPass As String, ByVal iScriptID As String, ByVal iRunType As String)
  If MyEIMacro(iUser, iPass, iScriptID, iRunType) = False Then
    ThisWorkbook.Sheets("EI_Data").Range("B5").Value = "Error calling VBA Automation!"
  End If
End Sub
Not that the excel instance called from PAD does not have to be visible! It may run in a separate invisible process, with gathering of error information! Using Outlook the error information can then be sent via e-mail!

In Power Automate Desktop you call the Start macro passing parameters separated by semocolons e.g.:
Start;%i_User%;%i_Pass%;%i_EIScriptID%;%i_EIRunType%

Example if Power Automate Desktop Flow added as attachments:
PAD_EI_Main.png
PAD_EI_Main.png (39.72 KiB) Viewed 15468 times
PAD_EI_SendResult.png
PAD_EI_SendResult.png (22.51 KiB) Viewed 15468 times