2.2: Step-by-Step on manually generating VBA Code for Process Runner

2.2: Step-by-Step on manually generating VBA Code for Process Runner

Users can run Process Runner through VBA-Excel. This will cover the entire process of creating a VBA macro in Excel to start Process Runner.

Below mentioned steps guide in manually generating VBA code for Process Runner.

1.Open Excel (in our case it is MM02.xlsx file).

2.Go to 'Developer' tab. If you do not find Developer tab then right click anywhere on the excel toolbar and select 'Customize the Ribbon' button. You can locate the 'Developer' on the right side under Main Tabs, please check it and click OK.

3.Developer tab is displayed. In the toolbar that appears, select button control as shown in the below screenshot.

PRTHCMDVBA-Ch--2-1 (10)

4.Draw the button on the excel sheet.You will automatically get a prompt of Assign Macro. Click on OK.

PRTHCMDVBA-Ch--2-1 (2)2

5.Open Visual Basic Editor from Developer -> Visual Basic.

PRTHCMDVBA-Ch--2-1 (3)2

6.Right click on VBAProject -> Insert -> Module.

PRTHCMDVBA-Ch--2-1 (4)2

7.Insert the VBA code in the editor.

8.Refer sample VBA code below for your reference.

PRTHCMDVBA-Ch--2-1 (5)2

Sample VBA Code:

Sub btnProrExecute_Click()

Dim ProRPath As String

Dim ProcessFilePath As String

Dim CmdParam As String

Dim ShowMsg As String

 

'=== Process Runner Parameters ====

'ProR: Name of the Process Runner exe in installation folder.

Second parameter is the path of Process Runner file that you want to run.

'|AutoRun: Indicates that the Process file is run without intervention, when set to True. Make sure that you provide the full path to the logon shortcut file if this parameter is set to true.

'|SilentMode: Indicates that the file is run silently without displaying any error messages.

'|LogonFile: Indicates the logon shortcut file that is used to connect to SAP.

'|ExcelFile: Indicates the full path of the external Excel file from where the data is uploaded, or to where the data gets extracted.

'|StartRow: Indicates the Excel row from where the run starts.

'|EndRow: Indicates the Excel row where the run stops.

'|CloseExcel: Indicates that the Excel file that used to run a Process file is closed after the run is complete. This parameter ignores the Edit > Excel Control > Basic > Close Excel after run setting.

'|SessionID: Indicates the session identifier of current run.

 

'=== Process Runner .exe file path ===

ProRPath = "C:\Program Files (x86)\Innowera\Process Runner\ProR.exe"

'=== Process file path ===

ProcessFilePath = "C:\Users\TestUser\Documents\Innowera\ProcessFiles\MM02_Change_Material.itf"

 '=== Make full command parameter to execute Process Runner with process file ===

CmdParam = Chr(34) & ProRPath & Chr(34) & " " & Chr(34) & ProcessFilePath & Chr(34)

ShowMsg = "Do you want to run current Excel file with Process Runner?" & vbCrLf & vbCrLf & "This Excel file will be executed with " & ProcessFilePath

 If MsgBox(ShowMsg, vbYesNo + vbQuestion) = vbYes Then

 CmdParam = CmdParam & " " & Chr(34) & "|ExcelFile=" & ThisWorkbook.FullName & Chr(34) & " " & _

Chr(34) & "|AutoRun=true" & Chr(34) '& " " & _

' Chr(34) & "|LogonFile=<LogonFileName>.ilf" & Chr(34) & " " & _

 'Chr(34) & "|SheetName=Sheet1" & Chr(34) & " " & _

  'Chr(34) & "|StartRow=2" & Chr(34) & " " & _

 'Chr(34) & "|EndRow=30" & Chr(34)

 

'=== Execute ===

Shell CmdParam, vbNormalFocus

End If

End Sub

9.Right click on the button and select Assign Macro.

PRTHCMDVBA-Ch--2-1 (6)2

10. Select the VBA method that was just created.

PRTHCMDVBA-Ch--2-1 (7)2

11. Please check your Macro security settings (Developer->Macro Security) before Run. This will determine your Macro execution level.

PRTHCMDVBA-Ch--2-1 (8)2

12. Once all set, click on the button 'Executing Process' to run the macro.

This concludes VBA through Process Runner.

Process Runner can also be executed from Command Prompt which gives a brief overview on the various command line parameters that Process Runner accepts.

 

 

Next

Chapter3: How to enable Trust Access to VBA Projects