[Solved] Should be a simple problem
-
- Posts: 3
- Joined: Fri Dec 14, 2007 4:31 am
[Solved] Should be a simple problem
All I need is a way for a Calc macro to change the sheet that is being shown in the workbook. I've got the name of the page that I want to jump to, but I can't find a function that will do the jump. This is the closest I can get...
sub goToPageByName
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim sheets as object
dim RollsSheet as object
dim JumpToSheet as object
dim SheetNameCell as object
dim TestCell as object
dim SheetName as String
rem ----------------------------------------------------------------------
rem get access to the document
document = thisComponent 'the current document should be of type Calc
sheets = document.getSheets()
RollsSheet = sheets.getByName("Rolls")
SheetNameCell = RollsSheet.getCellByPosition(5,1)
SheetName = SheetNameCell.String
JumpToSheet = sheets.getByName(SheetName)
rem this just to prove I've got the right value
TestCell = RollsSheet.getCellByPosition(6,1)
TestCell.String = SheetName
JumpToSheet.IsVisible = True
end sub
sub goToPageByName
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim sheets as object
dim RollsSheet as object
dim JumpToSheet as object
dim SheetNameCell as object
dim TestCell as object
dim SheetName as String
rem ----------------------------------------------------------------------
rem get access to the document
document = thisComponent 'the current document should be of type Calc
sheets = document.getSheets()
RollsSheet = sheets.getByName("Rolls")
SheetNameCell = RollsSheet.getCellByPosition(5,1)
SheetName = SheetNameCell.String
JumpToSheet = sheets.getByName(SheetName)
rem this just to prove I've got the right value
TestCell = RollsSheet.getCellByPosition(6,1)
TestCell.String = SheetName
JumpToSheet.IsVisible = True
end sub
Last edited by Hagar Delest on Tue Jun 10, 2008 2:03 pm, edited 2 times in total.
Reason: tagged the thread as Solved.
Reason: tagged the thread as Solved.
Re: Should be a simple problem
Is this what you're looking for? I invoke this code from a button to switch to "sheet2".
Sub ReturnToBSSheet()
dim oSheet as object
oSheet = ThisComponent.Sheets.getByName("sheet2")
ThisComponent.CurrentController.setActiveSheet(oSheet)
End Sub
Sub ReturnToBSSheet()
dim oSheet as object
oSheet = ThisComponent.Sheets.getByName("sheet2")
ThisComponent.CurrentController.setActiveSheet(oSheet)
End Sub
-
- Posts: 3
- Joined: Fri Dec 14, 2007 4:31 am
Re: Should be a simple problem
Ah, SetActiveSheet, that's exactly what I was looking for. Thanks a lot!
Thom
Thom
Re: Should be a simple problem
It's really work downloading and reading the relevant chapters of the SDK to get your head around all this. I realise it can be heavy going, but it still remains the best reference resource in my view. One of the architectural aspects that is embedded in Soffice is that it is designed to be run "headless". That is the concept of a document as an object (and the methods and properties that has) it is separate from the object that is used view it. This isn't the case in Excel fro example, which is why it is so difficult to run Excel as a slave task to a web-service for example: the concept that there is a viewer viewing the object is embedded in its design.
The concepts of the active sheet that is being shown is nothing to do with the sheet itself and is all to do with its being viewed. Hence this is a property of the controller object, and changing it is through a method of that controller: hence constructs such as
doc.CurrentController.setActiveSheet(doc.Sheet2)
The concepts of the active sheet that is being shown is nothing to do with the sheet itself and is all to do with its being viewed. Hence this is a property of the controller object, and changing it is through a method of that controller: hence constructs such as
doc.CurrentController.setActiveSheet(doc.Sheet2)
Ubuntu 11.04-x64 + LibreOffice 3 and MS free except the boss's Notebook which runs XP + OOo 3.3.
-
- Posts: 3
- Joined: Fri Dec 14, 2007 4:31 am
Re: [Solved] Should be a simple problem
I agree... My next question was going to be where can I find documentation on the macro language. I found something called "Programming StarOffice 8 Basic" but it doesn't show very many of the commands. Where can I find the SDK documentation?
Thanks!
Thom
Thanks!
Thom
Re: [Solved] Should be a simple problem
The main document is the OOo SDK. It is written mainly for the C++ and Java reader but if you are at all familiar with these then mapping the API calls back into Basic is reasonably straightforward. It's dense but it nonetheless remains the main reference work.
The OOo Wiki contains a developing Basic Guide. and there are various other resources such as Andrew Pitonyak's OpenOffice.org Macro Information
The OOo Wiki contains a developing Basic Guide. and there are various other resources such as Andrew Pitonyak's OpenOffice.org Macro Information
Ubuntu 11.04-x64 + LibreOffice 3 and MS free except the boss's Notebook which runs XP + OOo 3.3.
-
- Posts: 6
- Joined: Sun Dec 30, 2007 10:01 pm
Re: [Solved] Should be a simple problem
I have a problem with BASIC documentation. Over time I have accumulated Pitonyacs Book, his on-line Macro Document, the Star Office Guide of 2005 and the pages from the current wiki (which seem to be a copy of the Star Office document). Which should I throw away?
Peter Jones
Peter Jones
Re: [Solved] Should be a simple problem
Peter, you sound like me The one that you don't seem to have is the SDK. It's pretty essential. I never refer to Andrew's online macros now but I do keep a PDF version of this book on my PC. (You can legally download this if you own a copy of his book.) I also keep a copy of the Star Office 8 guide but mainly as a cross reference vehicle just in case any of the newbies use it. It is a good introduction, but just far too shallow. The Documentation team are moving and updating its content on the Wiki, so this will shortly be redundant.
Ubuntu 11.04-x64 + LibreOffice 3 and MS free except the boss's Notebook which runs XP + OOo 3.3.
-
- Posts: 6
- Joined: Sun Dec 30, 2007 10:01 pm
Re: [Solved] Should be a simple problem
Terry
Many thanks. Actually I do have the SDK but forgot to mention it. I also have the Xray Tool. So, I will get to know the SDK. The Xray Tool cross-references to the SDK. I will wait for the Documentation Team to do their stuff. The situation has greatly improved since I bought the book. Being a retired person who started programming years ago by keying 12-bit binary into a computer (guess what computer it was) I have had to get my head round objects and the OO Basic is very heavy in this area.
Peter
Many thanks. Actually I do have the SDK but forgot to mention it. I also have the Xray Tool. So, I will get to know the SDK. The Xray Tool cross-references to the SDK. I will wait for the Documentation Team to do their stuff. The situation has greatly improved since I bought the book. Being a retired person who started programming years ago by keying 12-bit binary into a computer (guess what computer it was) I have had to get my head round objects and the OO Basic is very heavy in this area.
Peter
Re: [Solved] Should be a simple problem
PDP-8. I can still remember PDP-8 assembler code. You didn't have a load accumulator just Two Add (TAD) nor a store accumulator instruction, just DCA (Deposit and Clear Accumulator) which clocked at about 24 microseconds, and a FOCAL system which could run in 4K 12 bit words. Welcome to the old farts club and Happy New Year.
Ubuntu 11.04-x64 + LibreOffice 3 and MS free except the boss's Notebook which runs XP + OOo 3.3.