cancel
Showing results for 
Search instead for 
Did you mean: 

Method arguments must be enclosed in parentheses

Ravikiran44
Level 3
Hi All,

I recorded a macro in excel to delimit the date format using following VB code,

Dim excel as Object = GetInstance(handle)

Range("B13").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWindow.SmallScroll Down:=3
Selection.TextToColumns Destination:=Range("B13"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
:=Array(1, 4), TrailingMinusNumbers:=True

But im getting error in the bold lines as "Method arguments must be enclosed in parentheses"
Please help Anyone !

------------------------------
Ravi kiran P
------------------------------
5 REPLIES 5

John__Carter
Staff
Staff
Macro code is VBA, which is not the same language as VB.Net, so you can't simply paste macro code into a BP code stage. However the two are similar, so you can use the VBA as a starting point. My guess is the error is asking for brackets in the function, eg Selection.TextToColumns(Destination:=Range..etc..Numbers:=True)

------------------------------
John Carter
Professional Services
Blue Prism
------------------------------

Hi Ravi,

The equivalent VB .NET code for this would be:

Dim wb, ws As Object
Dim excel, sheet As Object

Const xlDown As Int32 = -4121
Const xlDelimited As Int32 = 1
Const xlDoubleQuote As Int32 = 1

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

wb.Activate()
ws.Activate()
excel = ws.Application
sheet = excel.ActiveSheet

sheet.Range("B13").Select
sheet.Range("B13", excel.Selection.End(xlDown)).Select
excel.ActiveWindow.SmallScroll(Down:=3)
excel.Selection.TextToColumns(Destination:=sheet.Range("B13"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False, TrailingMinusNumbers:=True)​


Here, you need to pass the workbook and handle variable after you use the 'Create Instance' and 'Open Workbook' actions along with the name of the sheet as an input parameter.



------------------------------
----------------------------------
Hope it helps you out and if my solution resolves your query, then please mark it as the 'Best Answer' so that the others members in the community having similar problem statement can track the answer easily in future

Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Sr. Consultant - Automation Developer,
WonderBotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com

----------------------------------
------------------------------
---------------------------------------------------------------------------------------------------------------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.

Hi Devneet,

I tried executing but delimiting is not happening to the cells or do we have any other code stage to delimit the date format.

Below is the screenshot,

Thank you,

------------------------------
Ravi kiran P
------------------------------

Hi Ravi,

Your initial question was just around how to convert the equivalent VBA Macro Code To VB .NET which I initially did and shared with you. When I ran the macro code shared by you as well, I was not able to get any result at my end.

31913.png31914.png

It might be something is missing in this macro code which you have given. Can you tell me what exactly is your requirement so that I can give you a suitable solution as well to that. I guess you are trying to delimit the date value based on the '-' separator so that you get days, months and years separately. Is that correct understanding?

------------------------------
----------------------------------
Hope it helps you out and if my solution resolves your query, then please mark it as the 'Best Answer' so that the others members in the community having similar problem statement can track the answer easily in future

Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Sr. Consultant - Automation Developer,
WonderBotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com

----------------------------------
------------------------------
---------------------------------------------------------------------------------------------------------------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.

Hi Devneet,

Yes, Need to delimit the date as it contains space on the right side and not able to to convert that date into any format i.e MM/DD/YY,
without delimiting not able to format the particular cell .

------------------------------
Ravi kiran P
------------------------------