cancel
Showing results for 
Search instead for 
Did you mean: 

Excel VBO

Anonymous
Not applicable
Hello, Can anybody help me in Excel VBO, I want to select a range of rows and columns to generate a pivot table/chart using Excel VBO. Helping hand!!!!!! Regards Roopa Borkar
10 REPLIES 10

JēkabsRutkis
Level 4
dim right as Integer right = -4152 With GetWorkbook(handle,Nothing) .Sheets.Add .Sheets(1).Range(""B25:B30"").Select .Sheets(1).Range(""B25"").Activate .ActiveSheet.Shapes.AddChart2(251, 5).Select With .ActiveChart .FullSeriesCollection(1).Formula= """" 'excel formula you need for the table .ClearToMatchStyle .ChartStyle = ' select style you want, a number.. End With End With
Jekabs Rutkis [Designation] [JobTitle] [CompanyName] [City] [State] [Phone]

JēkabsRutkis
Level 4
This is a basic code! You should be able to find all you want in MS excel vba documentation https://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel https://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel
Jekabs Rutkis [Designation] [JobTitle] [CompanyName] [City] [State] [Phone]

RoopaBorkar
Level 2
I got an error while launching an excel which has space in between the file path For eg:- ""C:\Program Files\Blue Prism\XY Z.xlsx"" The path is broken into piece where you find space which results in error msg. I also tired removing space between them but again different error occurs as ""File path not found"". Is there any way that we can retain the space and open excel file Please help Regards Roopa Borkar

DiogoDavid
Level 3
Hi everyone. I am having a little trouble when I try to open an excel file. First i do the create instance (with the business object MS Excel VBO), where I select the enable events (true) and create an output (handle). Then, I create an action to show the excel, with the handle output from the previous step as the input. Then, I select Open Workbook, with the following inputs: ""Handle; File name as the path twoards the file in my computer; An output is also created, as the workname of that file. Sometimes, the process works just fine, but other times I get the following error: Internal : Could not execute code stage because exception thrown by code stage: Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED)) Do you know how can I solve this issue? Thank you so much, Kind regards, Diogo

Anonymous
Not applicable
Hi Diogo, I think the most common reason for the problem is that the Excel IDE is not fully opened when you try to call the command. Try putting a wait stage in front of you command and see if the problem still has a tendency to occur. When I had the problem I tried to seek advice, and found out that there could be several reasons or the exception to occur - so if a wait-stage does not solve the problem, it might be caused by one of the following problems: - Excel is not fully activated and licensed - OpenOffice is installed on the same PC - There are multiple instances of excel open.

Thank you very much, Kind regards

SnehasishMondal
Level 2
Hi All, I am using the following code to create a pivot table: string FilePath =@(Path); Excel.Application xlApp; Excel.Workbook xlWorkBook; Excel.Worksheet xlWorkSheet; object misValue = System.Reflection.Missing.Value; xlApp = new Excel.Application(); xlWorkBook = xlApp.Workbooks.Open(FilePath, 0, true, 5, """", """", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, ""\t"", false, false, 0, true, 1, 0); xlApp.WindowState = Excel.XlWindowState.xlMaximized; xlApp.Visible=true; //# of Rows // # of Colunm Excel.Workbook book = xlApp.ActiveWorkbook; Excel.Worksheet sheet = book.Worksheets[""Sheet1""] as Excel.Worksheet; Excel.PivotCaches pCaches = book.PivotCaches(); Excel.PivotCache pCache = pCaches.Create(Excel.XlPivotTableSourceType.xlDatabase, ""Sheet1!E10:EX075"", Excel.XlPivotTableVersionList.xlPivotTableVersion14); sheet = book.Worksheets[""Sheet2""] as Excel.Worksheet; sheet.Select(2); Excel.Range rngDes = sheet.get_Range(""A1"",""EX075""); Excel.PivotTable pTable = pCache.CreatePivotTable(rngDes, ""PivotTable1"", Excel.XlPivotTableVersionList.xlPivotTableVersion14,misValue); Excel.PivotField fieldQ = (Excel.PivotField)pTable.PivotFields(""Manager""); Excel.PivotField fieldQ = (Excel.PivotField)pTable.PivotFields(""Manager""); Excel.PivotField fieldA = (Excel.PivotField)pTable.PivotFields(""Department""); Excel.PivotField fieldc = (Excel.PivotField)pTable.PivotFields(""Balance""); fieldQ.Orientation = Excel.XlPivotFieldOrientation.xlRowField; fieldQ.Position = 1; fieldA.Orientation = Excel.XlPivotFieldOrientation.xlColumnField; fieldc.Orientation = Excel.XlPivotFieldOrientation.xlDataField; But I am geeting the following error: ""Page: Create Pivot Stage: Code Type: Error Action: Validate Description: Compiler error at line 1: Keyword, identifier, or string expected after verbatim specifier: @ Repairable: No"" Any suggestions on how to fix this. I am using Interop dll and namespace. Thanks in advance.Regards, Snehasish

Hi Roopa, This does happen if you are treating your Excel as an application and spying elements to work on it. When you launch any excel with a space in the path, it will show an error at the Launch Navigate stage. However, you should not face this problem if you are using the Excel VBO.

replace your first line string FilePath =@(Path); with this - string FilePath =(@Path);