[Solved] Chart - Modify referenced sheet
[Solved] Chart - Modify referenced sheet
Did some reading and there doesn't seem to be any way that I can get a chart to reference the current sheet it's located on through the normal interface. What I would like to do is after I copied a sheet with the copyByName() function to loop through all charts on the copied sheet and tell them to reference the copied sheet instead of the original. Looping through all the charts I know how to do but I can't figure out how to modify what sheet the chart reads from.
Last edited by kebab4you on Thu Aug 06, 2015 7:39 pm, edited 2 times in total.
OpenOffice 4.1.1
Windows 7
Windows 7
Re: [Calc] Chart - Modify referenced sheet
You'll probably need to poke around inside the chart object with Xray or MRI ([Tutorial] Introduction into object inspection with MRI) to figure out what property to change.
Graphs are actually really complicated objects. You might get some ideas from the few examples of creating or editing them with macros on these forums:
Code example for XY chart (original)
Code example for bar chart (modified from XY code)
Graphs are actually really complicated objects. You might get some ideas from the few examples of creating or editing them with macros on these forums:
Code example for XY chart (original)
Code example for bar chart (modified from XY code)
OpenOffice 4.1.1 on Windows 10, HSQLDB 1.8 split database
Re: [Calc] Chart - Modify referenced sheet
Do you know scenarios? http://forum.openoffice.org/en/forum/do ... hp?id=3004 (One chart with exchangable source ranges)
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: [Calc] Chart - Modify referenced sheet
Thank you, will take a look at it.MTP wrote:You'll probably need to poke around inside the chart object with Xray or MRI ([Tutorial] Introduction into object inspection with MRI) to figure out what property to change.
Graphs are actually really complicated objects. You might get some ideas from the few examples of creating or editing them with macros on these forums:
Code example for XY chart (original)
Code example for bar chart (modified from XY code)
Yeah read about it from another topic that you had commented on. From the sounds of it it's something the user have to activate for each sheet which won't work for me because I'm dealing with another end-user.Villeroy wrote:Do you know scenarios? http://forum.openoffice.org/en/forum/do ... hp?id=3004 (One chart with exchangable source ranges)
OpenOffice 4.1.1
Windows 7
Windows 7
Re: [Calc] Chart - Modify referenced sheet
There is only one visible sheet with one chart and one source range reflecting different data sets you can choose from a list box or from the navigator tool.kebab4you wrote:Yeah read about it from another topic that you had commented on. From the sounds of it it's something the user have to activate for each sheet which won't work for me because I'm dealing with another end-user.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: [Calc] Chart - Modify referenced sheet
Solved it in quite an easy matter with the following:
Haven't found a way to get a count on all charts that are on the page yet so I'm using the hardcoded value of 2. Since I only have two charts at the moment.
Code: Select all
Do While I < 2
oChart = oCopy.Charts.getByIndex(I)
Ranges = oChart.Ranges
Ranges(0).Sheet = oCopy.RangeAddress.Sheet
oChart.Ranges = Ranges
I = I+1
Loop
OpenOffice 4.1.1
Windows 7
Windows 7
Re: [Solved] Chart - Modify referenced sheet
Well yes, that's what scenarios do without a single line of Basic code
or if you want to:
or if you want to:
Code: Select all
objSheet.Scenarios.getByName("Plan_B").apply()
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice