ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Load picture from file to custom toolbar of Excel 2000 (https://www.excelbanter.com/excel-programming/369495-load-picture-file-custom-toolbar-excel-2000-a.html)

Padam

Load picture from file to custom toolbar of Excel 2000
 
Below code gives error as cb.Picture = picPicture does not exists.
Kindly help me. I am using it for Excel 2000 VBA.

Private Sub Workbook_Activate()
'sImageFile = ThisWorkbook.Path & "\ABC.jpg"
Dim c As CommandBar
Dim cb As CommandBarButton
Dim picPicture As IPictureDisp
Dim picMask As IPictureDisp 'you can also change the mask
Set picPicture = stdole.StdFunctions.LoadPicture(ThisWorkbook.Path &
"\ABC.jpg")

'optional - only of you have a mask file
'Set picMask = stdole.StdFunctions.LoadPicture("c:\...(your
path)...\maskName.bmp")
On Error Resume Next
Application.CommandBars("BarName").Delete

Set c = Application.CommandBars.Add("BarName", msoBarFloating, False,
True)
c.Enabled = True
c.Visible = True

Set cb = c.Controls.Add(msoControlButton)
cb.Style = msoButtonIcon
cb.Tag = "ButtonTest"

'Set the picture
cb.Picture = picPicture
'Set the mask
'cb.Mask = picMask
cb.OnAction = "ThisWorkbook.Test"
Set cb = Nothing
Set c = Nothing

End Sub



Jon Peltier

Load picture from file to custom toolbar of Excel 2000
 
The .Picture and .Mask properties of a command bar button were introduced in
Office XP (2002). In 2000, you must use the button's .PasteFace method to
apply a picture copied into the clipboard to the button.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Padam" wrote in message
...
Below code gives error as cb.Picture = picPicture does not
exists.
Kindly help me. I am using it for Excel 2000 VBA.

Private Sub Workbook_Activate()
'sImageFile = ThisWorkbook.Path & "\ABC.jpg"
Dim c As CommandBar
Dim cb As CommandBarButton
Dim picPicture As IPictureDisp
Dim picMask As IPictureDisp 'you can also change the mask
Set picPicture = stdole.StdFunctions.LoadPicture(ThisWorkbook.Path &
"\ABC.jpg")

'optional - only of you have a mask file
'Set picMask = stdole.StdFunctions.LoadPicture("c:\...(your
path)...\maskName.bmp")
On Error Resume Next
Application.CommandBars("BarName").Delete

Set c = Application.CommandBars.Add("BarName", msoBarFloating, False,
True)
c.Enabled = True
c.Visible = True

Set cb = c.Controls.Add(msoControlButton)
cb.Style = msoButtonIcon
cb.Tag = "ButtonTest"

'Set the picture
cb.Picture = picPicture
'Set the mask
'cb.Mask = picMask
cb.OnAction = "ThisWorkbook.Test"
Set cb = Nothing
Set c = Nothing

End Sub





Padam

Load picture from file to custom toolbar of Excel 2000
 
Hi Jon,

Thanks for reply. Is it possible if I include library of Office Xp (2002) in
Office 2000 (Excel 2000)? If yes kindly provide me names.

My requirements is : Display company logo in custom toolbar of Excel 2000
and image path should be read from directory. User does not want to copy
image in another excel sheet etc. but it is hidden from user in all respect.
If I read image path from directory then it solves my problem. I want image
in big form in toolbar of Excel 2000.

It would be really great help for me if you suggest me some solutions. My
yahoo id is

Thanks & Regards,
Padam Kumar Tripathi

"Jon Peltier" wrote:

The .Picture and .Mask properties of a command bar button were introduced in
Office XP (2002). In 2000, you must use the button's .PasteFace method to
apply a picture copied into the clipboard to the button.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Padam" wrote in message
...
Below code gives error as cb.Picture = picPicture does not
exists.
Kindly help me. I am using it for Excel 2000 VBA.

Private Sub Workbook_Activate()
'sImageFile = ThisWorkbook.Path & "\ABC.jpg"
Dim c As CommandBar
Dim cb As CommandBarButton
Dim picPicture As IPictureDisp
Dim picMask As IPictureDisp 'you can also change the mask
Set picPicture = stdole.StdFunctions.LoadPicture(ThisWorkbook.Path &
"\ABC.jpg")

'optional - only of you have a mask file
'Set picMask = stdole.StdFunctions.LoadPicture("c:\...(your
path)...\maskName.bmp")
On Error Resume Next
Application.CommandBars("BarName").Delete

Set c = Application.CommandBars.Add("BarName", msoBarFloating, False,
True)
c.Enabled = True
c.Visible = True

Set cb = c.Controls.Add(msoControlButton)
cb.Style = msoButtonIcon
cb.Tag = "ButtonTest"

'Set the picture
cb.Picture = picPicture
'Set the mask
'cb.Mask = picMask
cb.OnAction = "ThisWorkbook.Test"
Set cb = Nothing
Set c = Nothing

End Sub







All times are GMT +1. The time now is 03:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com