Copy image from form to toolbar

U

Ulf Nilsson

Hi,
How can I copy a picture I use with a button in a form to a button on a
toolbar?

Background:
I use Office XP Dev to create dll and I don't want to use the built-in
faceID but use my own created pictures.

/ Ulf
 
J

Jean-Guy Marcil

Ulf Nilsson was telling us:
Ulf Nilsson nous racontait que :
Hi,
How can I copy a picture I use with a button in a form to a button on
a toolbar?

Background:
I use Office XP Dev to create dll and I don't want to use the built-in
faceID but use my own created pictures.

A fast way would be to insert the picture in the Word Document, select it,
do CTRL-C, then access the toolbar button properties through the customize
menu, then, from right clicking on the button, do "Paste button image".
Unless you meant programmatically...

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
U

Ulf Nilsson

Hi,
Yes, I do mean programmatically.

/ Ulf

Jean-Guy Marcil said:
Ulf Nilsson was telling us:
Ulf Nilsson nous racontait que :


A fast way would be to insert the picture in the Word Document, select it,
do CTRL-C, then access the toolbar button properties through the customize
menu, then, from right clicking on the button, do "Paste button image".
Unless you meant programmatically...

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

Jean-Guy Marcil

Ulf Nilsson was telling us:
Ulf Nilsson nous racontait que :
Hi,
Yes, I do mean programmatically.

Have you looked up the PasteFace method?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

Jonathan West

Ulf Nilsson said:
Hi,
Yes, I do mean programmatically.

OK, there are two ways of putting a custom button with your own image onto a
toolbar.

1. You have a dummy toolbar which you keep invisible acting as a storage
place for all your custom buttons, and then use the Copy method of the
CommandBarControl object to copy it to some other (visible) toolbar.

2. You get your image into the clipboard and then use the PasteFace method
to apply it to the button.

I'm not aware of any other methods.

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
U

Ulf Nilsson

Hi,

I want to create a toolbar using vba (because I do not know how to manually
add a toolbar with Office XP Developer in an dll). How do I add my own images
on the buttons? I know how to do it with dot-files and that way does not
apply with dll-files.

How do I copy an image from a button in a form to the clipboard?
Copy/PasteFace does only apply to CommandBarButton. My question is about
forms.

/ Ulf
 
J

Jean-Guy Marcil

Ulf Nilsson was telling us:
Ulf Nilsson nous racontait que :
Hi,

I want to create a toolbar using vba (because I do not know how to
manually add a toolbar with Office XP Developer in an dll). How do I
add my own images on the buttons? I know how to do it with dot-files
and that way does not apply with dll-files.

You need to et the bitmap in the clipboard. TO do that, you must have the
bitmap available somewhere. I do not think you can get it from an already
existing userform button. Once the userform is created, you cannot extract
the image from a control... well, at least I have never seen it done.
How do I copy an image from a button in a form to the clipboard?
Copy/PasteFace does only apply to CommandBarButton. My question is
about forms.

and toolbars as stated in your subject line: "Copy image from form to
toolbar"

I think you are going to have to use Jonathan's idea about keeping a toolbar
around as a source of button images.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
U

Ulf Nilsson

Hi Jean-Guy and Jonathan,

I almost gave up finding any solution to my problem, BUT have found the
following solution (in a two years old document). I think I did not explain
my problem in a understandable way for you.


'***On startup
Dim cbToolbarOffice As Office.CommandBar
Dim picUpdate As IPictureDisp

Set picUpdate = stdole.StdFunctions.LoadPicture("C:\Temp\Update.bmp")

Set cbToolbarOffice = appHostApp.CommandBars.Add(Name:="AV", _
Position:=msoBarTop)

'***Buttons on the toolbar
Set cmbUpdate = cbToolbarOffice.Controls.Add(Type:=msoControlButton, _
Parameter:="AV_Toolbar")
With cmbUpdate
.Style = msoPicture
.Caption = "&The List"
.Picture = picUpdate
.TooltipText = "Show the list"
End With


Instead of "FaceId", I used "Picture" and it works.

Thanks both of you for your advice and patient.

/ Ulf
 
U

Ulf Nilsson

Hi Jean-Guy and Jonathan,

I almost gave up finding any solution to my problem, BUT have found the
following solution (in a two years old document). I think I did not explain
my problem in a understandable way for you.


'***On startup
Dim cbToolbarOffice As Office.CommandBar
Dim picUpdate As IPictureDisp

Set picUpdate = stdole.StdFunctions.LoadPicture("C:\Temp\Update.bmp")

Set cbToolbarOffice = appHostApp.CommandBars.Add(Name:="AV", _
Position:=msoBarTop)

'***Buttons on the toolbar
Set cmbUpdate = cbToolbarOffice.Controls.Add(Type:=msoControlButton, _
Parameter:="AV_Toolbar")
With cmbUpdate
.Style = msoPicture
.Caption = "&The List"
.Picture = picUpdate
.TooltipText = "Show the list"
End With


Instead of "FaceId", I used "Picture" and it works.

Thanks both of you for your advice and patient.

/ Ulf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top