Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default 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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default 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





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
add picture to custom toolbar DebC Excel Discussion (Misc queries) 2 February 17th 09 10:29 PM
Custom Toolbar to Insert Picture Landon[_2_] Excel Discussion (Misc queries) 0 February 21st 08 06:18 PM
Load image from directory for custom toolbar of Excel 2000 Padam Excel Worksheet Functions 0 August 5th 06 06:33 PM
Custom button on custom toolbar wants to re-load "Personal.xls" Aussie Dave Excel Programming 1 March 25th 05 10:19 AM
Cannot load picture from file! David Avsajanishvili[_2_] Excel Programming 0 February 28th 05 01:09 AM


All times are GMT +1. The time now is 04:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"