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

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
sanmahaan
Posts: 12
Joined: Wed May 10, 2017 3:53 pm

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

Post 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)
Last edited by RoryOF on Thu May 11, 2017 9:43 am, edited 3 times in total.
Reason: Added green tick [RoryOF, Moderator]
Libreoffice 4.0.2.2 on LINUX
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

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

Post 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.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
sanmahaan
Posts: 12
Joined: Wed May 10, 2017 3:53 pm

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

Post 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
Libreoffice 4.0.2.2 on LINUX
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

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

Post 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
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
sanmahaan
Posts: 12
Joined: Wed May 10, 2017 3:53 pm

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

Post by sanmahaan »

Thank you Villeroy...I shall try this and get back
Libreoffice 4.0.2.2 on LINUX
sanmahaan
Posts: 12
Joined: Wed May 10, 2017 3:53 pm

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

Post by sanmahaan »

Thank you Villeroy.. it worked with a some additions...this post can be closed
Libreoffice 4.0.2.2 on LINUX
Post Reply