cancel
Showing results for 
Search instead for 
Did you mean: 

OLE Excel chart

Former Member
0 Kudos

Hello

I have an ole Control of Microsoft Excel Worksheet. I populate data in a sheet and show the chart based on data in Another sheet. It works fine mostly but have one problem. If I have an excel file open while running the application, program writes the data in the already open excel file instead of sheet in OLE control. Therefore chart does not show any result.

Any suggestion is appreciated.

Thanks

Vinay

Code sample:

================

OleObject lole_workbook,  lole_worksheet

lole_workbook = ole_pareto.Object.application.workbooks(1)

lole_worksheet = lole_workbook.worksheets(1)

lole_worksheet.cells(1,1).value = "Dummy"

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member190719
Active Contributor
0 Kudos

The problem comes earlier on when you are first establishing the connection to Excel.  It's grabbing the existing instance rather than creating a new one.  What does that code look like?

Former Member
0 Kudos

Hi Bruce

I do not have any other code before this.

I am not creating the excel oleobject at run time as non Visual object, which one normally does as below

lole = create oleobject

li_result = lole.ConnectToNewObject("excel.application")
lole.workbooks.Open(ls_filename)

Instead I have inserted the ole Control on the face of a customised visual user object. There I chose "Create new" and then "Microsoft Excel Chart" from the list. It opens an excel file with a chart on the first tab and a table on the second tab. I manipulate the table and change the chart type and so on and then Close the excel. I see my chart on the ole Control. At run time I want to set the values in the second tab so that my chart is drawn dynamically based on the values I set.

It works fine normally but if I have an excel already open behind when I am running the code, my code writes the values in that excel and thus the OLE chart is not drawn properly because OLE excel sheet did not get new values.

Thanks

Vinay