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

cannot coerce argument type during corereflectioncal

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


Joined: 18 Apr 2005
Posts: 4

PostPosted: Mon Apr 18, 2005 9:18 am    Post subject: cannot coerce argument type during corereflectioncal Reply with quote

hi
i want to manipulate a writer-document from a calc-macro. I have collected some source-code:
Code:

Dim Doc As Object
Dim Url As String
Dim Dummy()
Url = "private:factory/swriter"
Doc = StarDesktop.loadComponentFromURL(Url, "_blank", 0, Dummy())
dim dispatcher as object
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Text"
args1(0).Value = "hallo"
dispatcher.executeDispatch(doc, ".uno:InsertText", "", 0, args1())
dispatcher.executeDispatch(doc, ".uno:InsertPara", "", 0, Array())

But if i run this, there is an error:
Quote:

cannot coerce argument type during corereflectioncall!

What does that mean? What can i do better?

Silverfish
Back to top
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Mon Apr 18, 2005 11:26 am    Post subject: Reply with quote

Do this better....
Code:
   docController = doc.getCurrentController()
   docFrame = docController.getFrame()
   dispatcher.executeDispatch(docFrame, ".uno:InsertText", "", 0, args1())
   dispatcher.executeDispatch(docFrame, ".uno:InsertPara", "", 0, Array())


See also....

Writer Examples
http://www.oooforum.org/forum/viewtopic.php?t=6049

Document model, controller and frame
http://www.oooforum.org/forum/viewtopic.php?t=5057

Making the Dispatcher easier to use
http://www.oooforum.org/forum/viewtopic.php?t=5058




Two articles on NewsForge by Andrew Pitonyak
http://www.oooforum.org/forum/viewtopic.php?p=52301#52301
Andrew Pitonyak has written a book that may be helpful.
OpenOffice.org Macros Explained
http://search.barnesandnoble.com/bookSearch/isbnInquiry.asp?sourceid=00393919607999617340&ISBN=1930919514&bfdate=12-11-2004+12:46:58


OpenOffice Macro Document by Andrew Pitonyak
http://www.pitonyak.org/AndrewMacro.sxw

Lots of macros here...
http://www.OOoMacros.org
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
silverfish
Newbie
Newbie


Joined: 18 Apr 2005
Posts: 4

PostPosted: Mon Apr 18, 2005 12:09 pm    Post subject: Reply with quote

Thanks

that works

Silverfish
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