need help macro loop (calc 3.1)

Alex Janssen alex at ourwoods.org
Sat Feb 27 18:07:41 UTC 2010


khobbos khobbos wrote:
>
> Dear sir
>
> I want to make a macro in calc 3.1
>
>
> Simply
>
> I wrote a formula in cell NB (A1)
>
> I want to jump to cell NB (A3) and paste the same
>
>
> So I record this macro and everything goes well
>
> sub Main13
>
> 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 ----------------------------------------------------------------------
>
> dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
>
> rem ----------------------------------------------------------------------
>
> dim args2(1) as new com.sun.star.beans.PropertyValue
>
> args2(0).Name = "By"
>
> args2(0).Value = 1
>
> args2(1).Name = "Sel"
>
> args2(1).Value = false
>
> dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args2())
>
> rem ----------------------------------------------------------------------
>
> dim args3(1) as new com.sun.star.beans.PropertyValue
>
> args3(0).Name = "By"
>
> args3(0).Value = 1
>
> args3(1).Name = "Sel"
>
> args3(1).Value = false
>
> dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args3())
>
> rem ----------------------------------------------------------------------
>
> dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
>
> end sub
>
> now I need to do a loop so I can for example repeat the same 10 times
>
> after googling I found this lines
>
> Dim I
>
> For I = 1 to 10
>
> ‘… Inner part of loop
>
> Next I
>
> So I edit the macro in this way
>
> sub Main13
>
> 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")
>
> dim i
>
> for i = 1 to 2
>
> rem ----------------------------------------------------------------------
>
> dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
>
> rem ----------------------------------------------------------------------
>
> dim args2(1) as new com.sun.star.beans.PropertyValue
>
> args2(0).Name = "By"
>
> args2(0).Value = 1
>
> args2(1).Name = "Sel"
>
> args2(1).Value = false
>
> dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args2())
>
> rem ----------------------------------------------------------------------
>
> dim args3(1) as new com.sun.star.beans.PropertyValue
>
> args3(0).Name = "By"
>
> args3(0).Value = 1
>
> args3(1).Name = "Sel"
>
> args3(1).Value = false
>
> dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args3())
>
> rem ----------------------------------------------------------------------
>
> dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
>
> next i
>
> end sub
>
> now I am getting this message : sequence element is not assignable by 
> given value!
>
>
>
> So plz can any one help me with this
>
>
>
>
> Many thanks
>
>
> Regard’s
>
>
> ------------------------------------------------------------------------
> Hotmail: Free, trusted and rich email service. Get it now. 
> <https://signup.live.com/signup.aspx?id=60969>
Looks like the macro recorder generated code to "Dim var as something".
I would try "dim i as integer", but I would also read up on Ooo macro 
code. Lookup the "dim" statement in some Ooo macro guide like Andrew 
Pitonyak's.

Alex

-- 
Ourwoods.org
 Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. - Albert Einstein (275)





More information about the ubuntu-users mailing list