Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Add custom icon using VBA

Hi, I have a toolbar that is stored in the personal.xls workbook and is
created each time I start Excel (2003 for xp). There are three buttons - the
first two have regular face id's, but the third I specifically designed a
button icon for. I just have no idea how to assign that icon to that macro.
I have saved the icon as a picture on sheet1 of my personal workbook (named
"calendar"), but I get an error message saying the picture is not found. I
also tried to activate the personal workbook but I kept getting more error
messages so I guess I am doing it wrong. Any help is appreciated!

Here is a snippet of my code:

c = 1
fID = 2167
Sheet1.Shapes("Calendar").Copy
For iCtr = LBound(MacNames) To UBound(MacNames)

With .Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & MacNames(iCtr)
.Caption = CapNamess(iCtr)
.Style = msoButtonIcon
If Not c = 3 Then
.FaceId = fID
Else
.PasteFace
End If
.TooltipText = TipText(iCtr)
End With
fID = fID - 2100
c = c + 1
Next iCtr
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Add custom icon using VBA

Here's one that I saved. Maybe you can pick the pieces out.

Did you create a worksheet with 5 pictures named pic1, pic2, pic3, pic4, pic5 on
it?

For i = LBound(mac_names) To UBound(mac_names)
Worksheets("PictSheetNameHere").Pictures("pic" & i + 1).Copy
With .Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & mac_names(i)
.Caption = cap_names(i)
.Style = msoButtonIconAndCaption
.PasteFace
.TooltipText = tip_text(i)
End With
Next i

SLW612 wrote:

Hi, I have a toolbar that is stored in the personal.xls workbook and is
created each time I start Excel (2003 for xp). There are three buttons - the
first two have regular face id's, but the third I specifically designed a
button icon for. I just have no idea how to assign that icon to that macro.
I have saved the icon as a picture on sheet1 of my personal workbook (named
"calendar"), but I get an error message saying the picture is not found. I
also tried to activate the personal workbook but I kept getting more error
messages so I guess I am doing it wrong. Any help is appreciated!

Here is a snippet of my code:

c = 1
fID = 2167
Sheet1.Shapes("Calendar").Copy
For iCtr = LBound(MacNames) To UBound(MacNames)

With .Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & MacNames(iCtr)
.Caption = CapNamess(iCtr)
.Style = msoButtonIcon
If Not c = 3 Then
.FaceId = fID
Else
.PasteFace
End If
.TooltipText = TipText(iCtr)
End With
fID = fID - 2100
c = c + 1
Next iCtr


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Add custom icon using VBA

Well ... it didn't quite work ...

I'm now getting the error message:

Run-time error '1004':
Method 'Worksheets' of object '_Global' failed

I am using face id's for two buttons and just want the one button with a
custom designed icon. 3 buttons total.

"Dave Peterson" wrote:

Here's one that I saved. Maybe you can pick the pieces out.

Did you create a worksheet with 5 pictures named pic1, pic2, pic3, pic4, pic5 on
it?

For i = LBound(mac_names) To UBound(mac_names)
Worksheets("PictSheetNameHere").Pictures("pic" & i + 1).Copy
With .Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & mac_names(i)
.Caption = cap_names(i)
.Style = msoButtonIconAndCaption
.PasteFace
.TooltipText = tip_text(i)
End With
Next i

SLW612 wrote:

Hi, I have a toolbar that is stored in the personal.xls workbook and is
created each time I start Excel (2003 for xp). There are three buttons - the
first two have regular face id's, but the third I specifically designed a
button icon for. I just have no idea how to assign that icon to that macro.
I have saved the icon as a picture on sheet1 of my personal workbook (named
"calendar"), but I get an error message saying the picture is not found. I
also tried to activate the personal workbook but I kept getting more error
messages so I guess I am doing it wrong. Any help is appreciated!

Here is a snippet of my code:

c = 1
fID = 2167
Sheet1.Shapes("Calendar").Copy
For iCtr = LBound(MacNames) To UBound(MacNames)

With .Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & MacNames(iCtr)
.Caption = CapNamess(iCtr)
.Style = msoButtonIcon
If Not c = 3 Then
.FaceId = fID
Else
.PasteFace
End If
.TooltipText = TipText(iCtr)
End With
fID = fID - 2100
c = c + 1
Next iCtr


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Add custom icon using VBA

When you get errors, you'll want to post the code and indicate the line that
caused the error.

But maybe this will help.

If Not c = 3 Then
.FaceId = fID
Else

worksheets("somesheet").Pictures("somepic").copy
.PasteFace
End If



SLW612 wrote:

Well ... it didn't quite work ...

I'm now getting the error message:

Run-time error '1004':
Method 'Worksheets' of object '_Global' failed

I am using face id's for two buttons and just want the one button with a
custom designed icon. 3 buttons total.

"Dave Peterson" wrote:

Here's one that I saved. Maybe you can pick the pieces out.

Did you create a worksheet with 5 pictures named pic1, pic2, pic3, pic4, pic5 on
it?

For i = LBound(mac_names) To UBound(mac_names)
Worksheets("PictSheetNameHere").Pictures("pic" & i + 1).Copy
With .Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & mac_names(i)
.Caption = cap_names(i)
.Style = msoButtonIconAndCaption
.PasteFace
.TooltipText = tip_text(i)
End With
Next i

SLW612 wrote:

Hi, I have a toolbar that is stored in the personal.xls workbook and is
created each time I start Excel (2003 for xp). There are three buttons - the
first two have regular face id's, but the third I specifically designed a
button icon for. I just have no idea how to assign that icon to that macro.
I have saved the icon as a picture on sheet1 of my personal workbook (named
"calendar"), but I get an error message saying the picture is not found. I
also tried to activate the personal workbook but I kept getting more error
messages so I guess I am doing it wrong. Any help is appreciated!

Here is a snippet of my code:

c = 1
fID = 2167
Sheet1.Shapes("Calendar").Copy
For iCtr = LBound(MacNames) To UBound(MacNames)

With .Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & MacNames(iCtr)
.Caption = CapNamess(iCtr)
.Style = msoButtonIcon
If Not c = 3 Then
.FaceId = fID
Else
.PasteFace
End If
.TooltipText = TipText(iCtr)
End With
fID = fID - 2100
c = c + 1
Next iCtr


--

Dave Peterson


--

Dave Peterson
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
custom icon Greg Excel Discussion (Misc queries) 3 October 31st 08 02:16 PM
custom icon in custom commandar Tim Rush Excel Programming 2 October 6th 07 04:56 PM
Custom Icon for an Excel File jpcmaddog Excel Programming 7 May 10th 07 10:46 AM
custom icon buttons FSt1 Excel Programming 3 August 15th 05 10:09 PM
custom icon buttons FSt1 Excel Programming 0 August 15th 05 05:52 PM


All times are GMT +1. The time now is 10:24 AM.

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

About Us

"It's about Microsoft Excel"