[Basic] set specific cell at startup

Hello, my workbook contain only one sheet. I want to open it on a specific cell selected, as A1 for example. With Basic in Calc, how to set a specific cell, to be displayed on start?

The following is from a recorded macro, but IMHO just edit your sheet and save when you are on the wished cell. Calc should open at the same place. (For older versions you may need to put some data in “user data” as position is logged oer user.)

rem ----------------------------------------------------------------------
	dim args1(0) as new com.sun.star.beans.PropertyValue
	args1(0).Name = "ToPoint"
	args1(0).Value = "A1:A1"
	
	dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())

The attached file contains a simple recorded macro, what is assigned to the Event: “View created”.
.
JumpToA1.ods (9.7 KB)

And here is the API equivalent of the recorded Dispacher related macro:

sub API_JumpToA1ofFirstSheet

	oDoc = Thiscomponent
	oSheets = oDoc.Sheets
	oSheet = oSheets.getbyindex(0) ' First sheet
	oCell = oSheet.getCellByposition(0, 0) 'Cell A1
	
	oView = oDoc.getCurrentController()
	oView.select(oCell)
end sub

@Wanderer I did not succeed.
@Zizi64 successful
Thanks for you replies :slight_smile: