cancel
Showing results for 
Search instead for 
Did you mean: 

Converting VBA macro to Blue Prism Code Stage

GavinRudling
Level 7
Good day team.
I'm wondering if it is possible to take code from an Excel macro and convert it within a code stage within Blue Prism. If possible, I would like to learn how to go about this.

Kind Regards
Gavin

------------------------------
Gavin Rudling
Digital Consultant & Developer
Cog3nt
Africa/Johannesburg
0813906789
------------------------------
1 REPLY 1

Hi Gavin

You can in a sense convert it to blueprism but it would require some editing on your part. The vba for macros and .net are a bit different but I often perform an action in excel and record it as a macro to help me speed up the development of the action in blueprism. Below is an example of an action recorded in excel and how that action is written in blueprism. There's a bit more work to get it in blueprism and you need to have your variables set etc, the action in my example simply selects a range of cells and drags the values to a specified range.

Macro recorded in excel
--------------------------------
Sub Macro1()
'
' Macro1 Macro
'
Range("A1:A3").Select
Selection.AutoFill Destination:=Range("A1:A20"), Type:=xlFillDefault
Range("A1:A20").Select
End Sub


Action as it looks in blueprism
----------------------------------
Dim wb, ws, source_range, fill_range As Object
Dim excel, sheet, range As Object

wb = GetWorkbook(Handle, Workbook)
ws = GetWorksheet(Handle, Workbook, Worksheet)

wb.Activate()
ws.Activate()

excel = ws.Application
sheet = excel.ActiveSheet
source_range = sheet.Range(SourceRange)
source_range.Select()
fill_range = sheet.Range(FillRange)
source_range.AutoFill(Destination:=fill_range)

Your source range is the cells selected and fill range is the range you want to drag the cells to. Hope this helps 🙂

------------------------------
Michael ONeil
Technical Lead developer
Everis Consultancy
Europe/London
------------------------------