cancel
Showing results for 
Search instead for 
Did you mean: 

VBA code for Blueprism

AsitabhaDeb
Level 6
Hi All,

My First question is:
I want to apply the macro in one excel file (.xlsx) without saving the macro because client does not want file extension with.xlsm.

Can I write VBA code directly in BP code stage?
Will it be possible if I copy VBA code after run the macro and paste in the BP code stage. will that work? but I dont want to save the macro.
Or any other way which will be easy. 

"I want a example of VBA code in BP code stage for opening a workbook."

My Second question is:
Also I would like to know which .DLL need to enter in initialize screen for running the VBA code.

Its Urgent, Please help. 

BR/Asitabha


------------------------------
Asitabha Deb
------------------------------
8 REPLIES 8

ewilson
Staff
Staff

@Asitabha Deb,

I don't think you'll be able to program VBA directly in a code stage. While you can program VB.NET in a code stage, VB.NET and VBA are not the same thing. Yes, there are some similarities, but code written in a code stage is JIT compiled using the .NET Framework while VB is interpreted within the host program (ex Excel, Word, etc).

Can you create a copy of the target Excel, perform your work with the macro inside of it, and then just delete it afterwards? 

Cheers,



------------------------------
Eric Wilson
Director, Partner Integrations for Digital Exchange
Blue Prism
------------------------------

Hi Eric,

Thanks for the reply.

Yes, I want to copy the macro from VB editor and paste in the BP code stage and then delete the macro because my client dont want to save the file in .XLSM format.

Will it work?

--
Thanks & Regard,

Asitabha Deb
9635405001


@Asitabha Deb,

No, trying to execute VBA in a code stage will not work.

What I meant by copying is can you make a copy of the actual .XLSX, inject the macro into the new temporary file, perform the calculations you need to​, and then either delete the macro from the temp file and save it (as .XLSX) or copy the update information from it (after running the macro) to the original .XLSX.

Cheers,

------------------------------
Eric Wilson
Director, Partner Integrations for Digital Exchange
Blue Prism
------------------------------

Hi Eric,

Excellent for quick response.

Based on your last option my confusion is over here is that after copying the macro from Temporary file when I paste it in the original .XLSX file, I need to save it and then excel want to save it as .xlsm because I need to save it as "Macro enabled workbook".

Correct me if I am wrong.

--
Thanks & Regard,

Asitabha Deb
9635405001


@Asitabha Deb,

After you've run the macro in the temporary copy of the .XLSX aren't you able to copy the values (cells, rows, charts, whatever) from the temporary file back into the original file? You don't need the macro at that point, just the updated values. It's a bit of a pain because you'd have to build your process to do this every time you want that .XLSX updated, but that's what RPA was created for. :beaming_face_with_smiling_eyes:

Cheers,


------------------------------
Eric Wilson
Director, Partner Integrations for Digital Exchange
Blue Prism
------------------------------

Hi Eric,

Thanks for your help. It is working now but as you said it is quite painful.

At last please tell me if I need to keep opening the temporary file (.XLSM) to run the macro in original file.

--
Thanks & Regard,

Asitabha Deb
9635405001


Hi  Asitabha, 

Well I faced similar circumstances before. Below are my two my recommendation to handle the scenario 

1. Make a separate file which calls the actual macro to perform  calculations on the target file. The temp file which you are using would be in xlsm format. SO you can trigger the macro from  blue prism. A slight change will be required 
2. You can make your own VB.NET code based on VBA code. Its pretty similar, but you need to tweak with variables and functions. You can refer to the below link for compiling and error handling. Refer to stack overflow

https://www.tutorialspoint.com/compile_vb.net_online.php

3. Check Digital exchange for advanced excel functions. May be all you need is custom object 



------------------------------
Susamay Halder
------------------------------

MiguelCarrillo
Level 5
You could create a new action inside the Microsoft Excel VBO, where you can implemente the code of the macro that you built. 
In order to make it work, you need to make some changes, and based on what are you trying to do it could be easy or hard.
If you want, I can help you to try to port your macro into a code stage in blue prism.


------------------------------
Miguel Carrillo
------------------------------