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

Need help in writing a simple macro

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


Joined: 12 Dec 2006
Posts: 1

PostPosted: Tue Dec 12, 2006 3:24 pm    Post subject: Need help in writing a simple macro Reply with quote

Hello, I'm really new into programming macros
And I have something probably very easy to do, but for me, it's a leviathan.
Well, I've tried to start with the macro's writer into OoO, but hum, it seems confuse.

Here is what I want to do :
I need to insert 21 groups of rows into my sheet at the current cell, with a default value (like "0" or "-")

here is my code :

Code:
REM  *****  BASIC  *****

Sub Main
dim document   as object
dim dispatcher as object

document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

For i = 0 to 20
dispatcher.executeDispatch(document, ".uno:InsertRows", "", 0, Array())
dim args2(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "StringName"
args1(0).Value = "-"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args1())
Next i
End Sub


but I have an error on this line :

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



I'm sure it's really easy, but as I'm really new at this...

Please help me,
Raph
Back to top
View user's profile Send private message
Zarius
OOo Enthusiast
OOo Enthusiast


Joined: 21 Jan 2005
Posts: 142
Location: Brisbane, Australia

PostPosted: Tue Dec 12, 2006 5:21 pm    Post subject: Reply with quote

Hi Raph,

The error message is a bit cryptic, but I got it to work by moving the "dim args2" (which should be args1, by the way) out of the loop, as per the code below:

Code:
dim args1(0) as new com.sun.star.beans.PropertyValue

For i = 0 to 20
dispatcher.executeDispatch(document, ".uno:InsertRows", "", 0, Array())
args1(0).Name = "StringName"
args1(0).Value = str(i) ' made it write the number, to make sure all 20 rows work

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args1())
Next i

_________________
Zarius Tularial. (WinXP - OOo 1.1.4, FedoraCore 4 - OOo 2.0, RHEL4 - StarOffice 7)
Quoots - a quicker way to open your documents and fill in template details in OOo. (written in OOBasic)
Back to top
View user's profile Send private message Visit poster's website
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