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

Embed image into macro dialog box

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


Joined: 15 May 2008
Posts: 2

PostPosted: Thu May 15, 2008 6:28 am    Post subject: Embed image into macro dialog box Reply with quote

Hello! I've written a macro and am trying to create a dialog box with a company logo. However when I specify the image, I can only specify it by its location in file system. I'd like to embed it, but there is no such option. I can embed them into my spreadsheet, but is it possible to address it from macro dialog box? (so that image in dialog box is taken from the spreadsheet in question)?

Best Regards
Back to top
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Sat May 17, 2008 1:35 am    Post subject: Reply with quote

Hi,

try the following:
Code:
Sub Main

'retrieve the picture. The picture is the only element in the (hidden) sheet image1.
'insert the picture into sheet image1 with the checkbox Link unchecked
oImage1 = ThisComponent.sheets.getByName("image1").Drawpage.getByIndex(0)

' create the dialog
oDialogModel = createUnoService( "com.sun.star.awt.UnoControlDialogModel" )
oDialogModel.Title = "My Image" 
oDialogControl = createUnoService( "com.sun.star.awt.UnoControlDialog" )
oDialogControl.setModel( oDialogModel )
oDialogControl.setPosSize(0, 0, 250, 250, com.sun.star.awt.PosSize.POSSIZE)

 
oImageControlModel = oDialogModel.createInstance( "com.sun.star.awt.UnoControlImageControlModel" )
oDialogModel.insertByName( "MyImage", oImageControlModel )

oImageControlControl = oDialogControl.getControl( "MyImage")
oImageControlControl.setPosSize(20, 20, 200, 200, com.sun.star.awt.PosSize.POSSIZE)

oDialogControl.setVisible(true)
oImageControlModel.Graphic = oImage1.Graphic
oDialogControl.execute

End Sub
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