<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic RE: How to ensure &amp;quot;Run macro&amp;quot; executed successfully in Product Forum</title>
    <link>https://community.blueprism.com/t5/Product-Forum/How-to-ensure-quot-Run-macro-quot-executed-successfully/m-p/87297#M38029</link>
    <description>&lt;P&gt;Hi Bhavithra, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add error handling within macro with message box&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On Error GoTo Ermsg&lt;/P&gt;
&lt;P&gt;Ermsg:&lt;/P&gt;
&lt;P&gt;MsgBox "The following error occurred:"&amp;amp;Err.Description&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Joshna Dammala&lt;BR /&gt;RPA Developer&lt;BR /&gt;Asia/Kolkata&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
    <pubDate>Wed, 15 Mar 2023 05:56:00 GMT</pubDate>
    <dc:creator>Joshna_16</dc:creator>
    <dc:date>2023-03-15T05:56:00Z</dc:date>
    <item>
      <title>How to ensure "Run macro" executed successfully</title>
      <link>https://community.blueprism.com/t5/Product-Forum/How-to-ensure-quot-Run-macro-quot-executed-successfully/m-p/87295#M38027</link>
      <description>&lt;P&gt;I am using "Run macro"&amp;nbsp; action in the Excel VBO to call the macro code in the excel sheet. I just want to ensure if the macro was executed successful or not.&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Bhavithra L&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Mar 2023 11:04:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/How-to-ensure-quot-Run-macro-quot-executed-successfully/m-p/87295#M38027</guid>
      <dc:creator>Bhavithra</dc:creator>
      <dc:date>2023-03-14T11:04:00Z</dc:date>
    </item>
    <item>
      <title>RE: How to ensure "Run macro" executed successfully</title>
      <link>https://community.blueprism.com/t5/Product-Forum/How-to-ensure-quot-Run-macro-quot-executed-successfully/m-p/87296#M38028</link>
      <description>&lt;P&gt;Hi Bhavithra,&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I would advise you to build an Error Handler in the Macro that generates an ErrorLog.txt should the macro fail and then parse the File via BP. Something like this:&lt;/P&gt;
&lt;PRE class="language-vb"&gt;&lt;CODE&gt;Public Function LogFile_WriteError(ByVal sRoutineName As String, _
                                   ByVal sMessage As String)
Dim sText As String
   On Error GoTo ErrorHandler
   If (g_objFSO Is Nothing) Then
      Set g_objFSO = New FileSystemObject
   End If
   If (g_scrText Is Nothing) Then
      If (g_objFSO.FileExists("&amp;lt;YourPath&amp;gt;\errorLog.txt") = False) Then
         Set g_scrText = g_objFSO.OpenTextFile("&amp;lt;YourPath&amp;gt;\errorLog.txt", IOMode.ForWriting, True)
      Else
         Set g_scrText = g_objFSO.OpenTextFile("&amp;lt;YourPath&amp;gt;\errorLog.txt", IOMode.ForAppending)
      End If
   End If
   sText = sText &amp;amp; "" &amp;amp; vbCrLf
   sText = sText &amp;amp; Format(Date, "dd.MM.yyyy") &amp;amp; "-" &amp;amp; Time() &amp;amp; vbCrLf
   sText = sText &amp;amp; " " &amp;amp; sRoutineName &amp;amp; vbCrLf
   sText = sText &amp;amp; " " &amp;amp; sMessage &amp;amp; vbCrLf
   g_scrText.WriteLine sText
   g_scrText.Close
   Set g_scrText = Nothing
   Exit Function
ErrorHandler:
   g_scrText.WriteLine sText
   g_scrText.Close
   Set g_scrText = Nothing
 
End Function&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;You must declare two global variables in order for this to work:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Public g_objFSO As Scripting.FileSystemObject&lt;BR /&gt;Public g_scrText As Scripting.TextStream&lt;/P&gt;
&lt;P&gt;The &amp;lt;YourPath&amp;gt; tag should be replaced by your process folder or wherever you want to store the ErrorLog, and this should be accessible to both the Macro and Process.&lt;/P&gt;
&lt;P&gt;I hope it helps&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Ramón Requena López&lt;BR /&gt;RPA Developer&lt;BR /&gt;Magenta Telekom&lt;BR /&gt;------------------------------&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 12:41:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/How-to-ensure-quot-Run-macro-quot-executed-successfully/m-p/87296#M38028</guid>
      <dc:creator>RamónRequena_L1</dc:creator>
      <dc:date>2023-03-14T12:41:00Z</dc:date>
    </item>
    <item>
      <title>RE: How to ensure "Run macro" executed successfully</title>
      <link>https://community.blueprism.com/t5/Product-Forum/How-to-ensure-quot-Run-macro-quot-executed-successfully/m-p/87297#M38029</link>
      <description>&lt;P&gt;Hi Bhavithra, &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add error handling within macro with message box&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On Error GoTo Ermsg&lt;/P&gt;
&lt;P&gt;Ermsg:&lt;/P&gt;
&lt;P&gt;MsgBox "The following error occurred:"&amp;amp;Err.Description&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Joshna Dammala&lt;BR /&gt;RPA Developer&lt;BR /&gt;Asia/Kolkata&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Wed, 15 Mar 2023 05:56:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/How-to-ensure-quot-Run-macro-quot-executed-successfully/m-p/87297#M38029</guid>
      <dc:creator>Joshna_16</dc:creator>
      <dc:date>2023-03-15T05:56:00Z</dc:date>
    </item>
    <item>
      <title>RE: How to ensure "Run macro" executed successfully</title>
      <link>https://community.blueprism.com/t5/Product-Forum/How-to-ensure-quot-Run-macro-quot-executed-successfully/m-p/87298#M38030</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I define two ranges on a specific sheet in the Excel workbook: MacroInput (used to pass input values to the macro), and MacroResult (used to find out if the macro completed successfully, or, if not, what the error description from Excel is). The macro reads the MacroInput range if necessary to get a date, filepath, etc. If it completes without errors the macro will write Success in the MacroResult range, which is then read by the BP process. If an error accurs, the macro writes the Excel error description to MacroResult. Here is an example:&lt;/P&gt;
&lt;P&gt;Public Sub Import_AP_Data()&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Dim &amp;nbsp;MyPath As String&lt;BR /&gt;&amp;nbsp; &amp;nbsp; MyPath = ThisWorkbook.Sheets(MainSht).Range("MacroInput").Value&lt;BR /&gt;&amp;nbsp; &amp;nbsp; On Error GoTo IAPDerr&lt;/P&gt;
&lt;P&gt;(do stuff)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; ThisWorkbook.Sheets(MainSht).Range("MacroResult").Value = "Success"&lt;BR /&gt;cleanup:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; On Error Resume Next&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Application.CutCopyMode = False&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Application.DisplayAlerts = True&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Application.ScreenUpdating = True&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Exit Sub&lt;BR /&gt;IAPDerr:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; ThisWorkbook.Sheets(MainSht).Range("MacroResult").Value = Err.Description&lt;BR /&gt;&amp;nbsp; &amp;nbsp; GoTo cleanup&lt;BR /&gt;End Sub&lt;/P&gt;
&lt;P&gt;The macro must not have any messageboxes or other popups.&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Hutch&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;Thomas Hutchins&lt;BR /&gt;Lead Developer&lt;BR /&gt;Discover&lt;BR /&gt;America/Chicago&lt;BR /&gt;------------------------------&lt;BR /&gt;</description>
      <pubDate>Wed, 15 Mar 2023 14:13:00 GMT</pubDate>
      <guid>https://community.blueprism.com/t5/Product-Forum/How-to-ensure-quot-Run-macro-quot-executed-successfully/m-p/87298#M38030</guid>
      <dc:creator>ThomasHutchins</dc:creator>
      <dc:date>2023-03-15T14:13:00Z</dc:date>
    </item>
  </channel>
</rss>

