Page 1 of 1

[Solved] Setting all screenshots in Calc sheet to anchor to

Posted: Wed May 10, 2017 6:09 pm
by sanmahaan
Topic : Setting all screenshots in Calc sheet to anchor to cell
I am new to LibreOffice. I am used to macros in the XL environ
Wish to have the code to set all the screen shots in the Calc sheet ( and maybe for all sheets in the calc workbook)
to anchor on cell and not on page.
Thanks in advance.

( Not sure if i had posted this query in the wrong forum of CALC..but it does not seem to be listed too.. so am posting it here)

Re: Setting all screenshots in Calc sheet to anchor to cell

Posted: Wed May 10, 2017 6:23 pm
by Zizi64
The MS VBA for the Excel and the API functions of the AOO/LO are not compatible. You must rewrite all of your VBA macros based on the API (Application programming Interface) and one of the supportesd programming language.

Please upload an example document and some macro code here.

The LibreOffice has a littlebit higher compatibility (with the VBA codes) than the Apache OpenOffice.

Re: Setting all screenshots in Calc sheet to anchor to cell

Posted: Wed May 10, 2017 6:26 pm
by sanmahaan
I am not referring to any VB macros. I do not want to convert any macros.
Just want a simple code that will loop thru all the screen shots that I have put in CALC sheet, to anchor on the cell
as else on inserting rows, the entire document gets misaligned.
Thank you

Re: Setting all screenshots in Calc sheet to anchor to cell

Posted: Wed May 10, 2017 9:24 pm
by Villeroy
Select all shapes on the current sheet so you can right-click the whole collection and do whatever you need.

Code: Select all

Sub selectAllShapes()
	ctrl = ThisComponent.getCurrentController()
	sh = ctrl.getActiveSheet()
	dp = sh.getDrawPage()
	sc = createUnoService("com.sun.star.drawing.SvxShapeCollection")
	n = dp.getCount()
	for i = 0 to n-1
		sc.add(dp.getByIndex(i))
	next
	ctrl.select(sc)
End Sub

Re: Setting all screenshots in Calc sheet to anchor to cell

Posted: Thu May 11, 2017 4:55 am
by sanmahaan
Thank you Villeroy...I shall try this and get back

Re: Setting all screenshots in Calc sheet to anchor to cell

Posted: Thu May 11, 2017 9:33 am
by sanmahaan
Thank you Villeroy.. it worked with a some additions...this post can be closed