Merge cells in excel

Hi @the.christopoulos

Try this

Thanks
Ashwin S

Yes, exactly. I recorded the VBA and then I user invoke code to run it.

He cannot install any packages

You can create VBA (macro file) and run this from UiPath - Execute macro in Excel activities.

Hi @the.christopoulos

you can use execute macro and pass the function name and try

Thanks
Ashwin S

@pllo2ptk @AshwinS2
I can not execute macros also because of security policy in the Organization.

I need to invoke vba code, but I do not know exactly how it should be. :frowning:

Does anybody know how to write vba code for invoking just to merge two different ranges of cells in the active excel which is already open , because I am inside excel application scope activity?

You can always create your own activity for merging files (write it in C#).
There is no possibility to invoke VBA code from the Uipath directly.

@pllo2ptk

Why not? Are you sure? Then, what is Invoke code activity for?

Invoke Code is for run Visual Basic (not Visual Basic for Application) code.
Anyway, you can try find guides how to manipulate excel file with VB.

Hi @the.christopoulos

Why don’t you use the merge activity on UiPath ?

@mz3bel Which one exactly is this ? I do not have any merge for excel. Only merge datatable

@the.christopoulos

Yes, you read the excel file and store your data on a datatable, than use merge to merge the data you want…

@mz3bel I just want to merge cells in excel, in order to make A1:C1 to show like 1 cell
Not in datatable.

will be like this:

Dim xl As Excel.Application = New Excel.ApplicationClass()
Dim wb As Excel.Workbook = xl.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorkshe, et)
Dim ws As Excel.Worksheet = CType(wb.ActiveSheet, Excel.Worksheet)
Dim range As Excel.Range = ws.get_Range(ws.Cells(1, 1), ws.Cells(1, 2))
range.Merge(True)

@bcorrea I put the code you mentioned and I get the below errors:

image

i imagined you had imported the namespace already, you need to add this import to your project:
Microsoft.Office.Interop.Excel

@bcorrea In the available namespaces for import there is not such namespace.

it does not begin with Excel… it is Microsoft.Office.Interop.Excel

@bcorrea It is imported but I still get the same error.

I think we use the Invoke VBA code from Excel Application Scope. It even works for non xlsm file type.