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

Macro that inserts all images from dir to *.odt

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


Joined: 10 Jan 2007
Posts: 1

PostPosted: Wed Jan 10, 2007 8:46 pm    Post subject: Macro that inserts all images from dir to *.odt Reply with quote

I've made such macro:
Code:
sub InsertPNGs
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(3) as new com.sun.star.beans.PropertyValue
args1(0).Name = "FileName"
args1(0).Value = "C:\Documents and Settings\Sebo\My Documents\TSiD\L4\R1\"&Dir$("C:\Documents and Settings\Sebo\My Documents\TSiD\L4\R1\*.png")
args1(1).Name = "FilterName"
args1(1).Value = "<Wszystkie formaty>"
args1(2).Name = "AsLink"
args1(2).Value = false
args1(3).Name = "Style"
args1(3).Value = "Grafika"

do
rem MsgBox args1(0).Value
 dispatcher.executeDispatch(document, ".uno:InsertGraphic", "", 0, args1())
 dispatcher.executeDispatch(document, ".uno:SetAnchorToChar", "", 0, Array())
 dispatcher.executeDispatch(document, ".uno:InsertPara", "", 0, Array())
 args1(0).Value = "C:\Documents and Settings\Sebo\My Documents\TSiD\L4\R1\"&Dir$
loop until args1(0).Value="C:\Documents and Settings\Sebo\My Documents\TSiD\L4\R1\"

end sub


But it does not work as I expected Confused
I think the problem is because ooWrter does not move selectoin from inserted image before inserting paragraph ;]
I don't know which method can I use to make it to do so and I can't find any documentation of avaliable uno methods Sad
Back to top
View user's profile Send private message
thralia
Newbie
Newbie


Joined: 19 Feb 2007
Posts: 1

PostPosted: Mon Feb 19, 2007 4:04 pm    Post subject: re : Reply with quote

sebo, as written in this post : http://www.oooforum.org/forum/viewtopic.phtml?t=43912
try to add the following line after the image is inserted :
dispatcher.executeDispatch(document, ".uno:Escape", "", 0, Array())

This could give :
dispatcher.executeDispatch(document, ".uno:InsertGraphic", "", 0, args1())
dispatcher.executeDispatch(document, ".uno:Escape", "", 0, Array())

for example.

Ciao,

Mikaël
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