cancel
Showing results for 
Search instead for 
Did you mean: 

Use VBA Code - WeekdayName & WeekDay

HannesTHEISL
Level 2
Hello, I want to use this VBA Code Stage in RPA: GetWeekDay = WeekdayName(Weekday(Date, vbMonday), True) but I got this errormessages: Weekday and WeekdayName is not declared.   In Excel VBA this Code Stage works well! I would be happy about your help :)    
4 REPLIES 4

Denis__Dennehy
Level 15
Always experiement with the functions available in a calculation stage before you create bespoke code stages.  There is a FormatDate function where you can use the ""dddd"" as the format to get the full day as text.

John__Carter
Staff
Staff
VBA is not the same as VB.Net and you can't simply paste from an Excel macro into a BP code stage. The two languages are similar but they are not the same, and an explanation on how to rewrite VBA as VB.Net is beyond the scope of this forum I'm afraid.

Anton__Hosang
Level 5
Visual Basic functions are not included by default even though you are using VB.NET You can go to the 'Code Options' section by double-clicking the box in the Initialise page of your object. Then import Microsoft.VisualBasic namespace, and voila, you have Visual Basic functions. It is 5th on my list of Namespace Imports in the image      

Denis__Dennehy
Level 15
I recommend strongly against using code stages where what you want to do can be done in a calculation stage.  For Enterprise RPA you should be moving away from creating bespoke scripting code as much as you can - your solution may be supported in future by someone with less coding experience than yourself.   Many clients have selected Blue Prism because it is more of a business tool that in most scenarios will not require coding. What Theisl wants to do is perfectly easy to figure out using the calculation stage expression builder - so there is no need for code FormatDate([Weekday], ""dddd"")=""Monday