OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Help: Why won't this Calc macro fully execute?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
mibadt
General User
General User


Joined: 17 Mar 2006
Posts: 10

PostPosted: Tue Mar 21, 2006 2:35 am    Post subject: Help: Why won't this Calc macro fully execute? Reply with quote

Hi,
I have recorded a simple data filtering macro in Calc 2.0.2.
While I got the desired results while recording the macro (and during a previous "dry run"), when I ran the macro, it only selects the data source of the filtering and that's it (details ahead). Can somebody please help me fix that macro.

TIA

Following are supporting details and the macro itself:
It is a multiple sheet Calc (ver 2.0.2) spreadsheet. Sheet "ST_Transfer" contains, among others, a named range ("Interim_ST") of 3 columns X approx 50 rows. The first row contains the columns headins (which are Type, Ex, Last) and the following rows contain varios numeric (no functions) values (the last 2 columns) and either (string) C or P in the Type column.

The macro is expected to perform the following:
a. Select the "Interim_ST" data (this will be the "source" data for the filtering)
b. Perform Data-->Filter-->Standard Filter with Type=C and copy the filtered data into another sheet ($Raw_ST.$A$1).
c. Repeat a & b above, this time with criteria Type=P and destination $Raw_ST.$F$1.

As said when I try running this macro, it completes with "Interim_ST" selected (and both destinations empty).

==========The Macro as recorded by Calc================

sub Data_Filtering
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Navigator"
args1(0).Value = true

dispatcher.executeDispatch(document, ".uno:Navigator", "", 0, args1())

rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "ToPoint"
args2(0).Value = "Interim_ST"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args2())

rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "Navigator"
args3(0).Value = false

dispatcher.executeDispatch(document, ".uno:Navigator", "", 0, args3())

rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:DataFilterStandardFilter", "", 0, Array())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:FilterExecute", "", 0, Array())

rem ----------------------------------------------------------------------
dim args6(0) as new com.sun.star.beans.PropertyValue
args6(0).Name = "Navigator"
args6(0).Value = true

dispatcher.executeDispatch(document, ".uno:Navigator", "", 0, args6())

rem ----------------------------------------------------------------------
dim args7(0) as new com.sun.star.beans.PropertyValue
args7(0).Name = "ToPoint"
args7(0).Value = "Interim_ST"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args7())

rem ----------------------------------------------------------------------
dim args8(0) as new com.sun.star.beans.PropertyValue
args8(0).Name = "Navigator"
args8(0).Value = false

dispatcher.executeDispatch(document, ".uno:Navigator", "", 0, args8())

rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:DataFilterStandardFilter", "", 0, Array())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:FilterExecute", "", 0, Array())


end sub
Back to top
View user's profile Send private message
JeromeC
General User
General User


Joined: 13 Oct 2005
Posts: 37
Location: France - Nantes

PostPosted: Tue Mar 21, 2006 12:34 pm    Post subject: Reply with quote

Hi,

it's not the easiest way to filter a datarange in calc with the macro recorder and dispatcher.

See this post, it can be useful for your problem :
http://www.oooforum.org/forum/viewtopic.phtml?t=11473&highlight=filterdescriptor

Jerome.
Back to top
View user's profile Send private message
mibadt
General User
General User


Joined: 17 Mar 2006
Posts: 10

PostPosted: Tue Mar 21, 2006 8:12 pm    Post subject: Thanks Reply with quote

Thanks Jerome,
Although I'm a newbie with OO Macro, I get the general direction and will try following.
Take Care !

Michael
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group