Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Draw Buttons


Hi Dave,
Thanks for all the help.( Same to you, ste mac :) )
What I would like is to write code that, like the buttons code :

Sub testme()

Dim myRng As Range
Dim myCell As Range
Dim wks As Worksheet
Dim myBTN As Button

Set wks = ActiveSheet
With wks
.Buttons.Delete 'remove existing buttons???
Set myRng = .Range("a1:a10")
For Each myCell In myRng.Cells
With myCell
Set myBTN = .Parent.Buttons.Add(0, 0, 0, 0)
myBTN.Name = "BTN_" & .Address(0, 0)
myBTN.OnAction = ThisWorkbook.Name & "!myBTNmacro"
myBTN.Caption = "Click Me"
End With
Next myCell
End With
End Sub

Except that I would like the button to look like an image file. I
there a property like myBtn.Image or something like that? Or do I hav
to add an image that is clickable? If so, how do I do it

--
junx1

-----------------------------------------------------------------------
junx13's Profile: http://www.excelforum.com/member.php...nfo&userid=562
View this thread: http://www.excelforum.com/showthread.php?threadid=26151

  #2   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Draw Buttons

hi,
yes there is a property. the Picture property.
but i am not sure about the code syntax.


-----Original Message-----

Hi Dave,
Thanks for all the help.( Same to you, ste mac :) ).
What I would like is to write code that, like the buttons

code :

Sub testme()

Dim myRng As Range
Dim myCell As Range
Dim wks As Worksheet
Dim myBTN As Button

Set wks = ActiveSheet
With wks
.Buttons.Delete 'remove existing buttons???
Set myRng = .Range("a1:a10")
For Each myCell In myRng.Cells
With myCell
Set myBTN = .Parent.Buttons.Add(0, 0, 0, 0)
myBTN.Name = "BTN_" & .Address(0, 0)
myBTN.OnAction = ThisWorkbook.Name & "!myBTNmacro"
myBTN.Caption = "Click Me"
End With
Next myCell
End With
End Sub

Except that I would like the button to look like an image

file. Is
there a property like myBtn.Image or something like that?

Or do I have
to add an image that is clickable? If so, how do I do it ?


--
junx13


----------------------------------------------------------

--------------
junx13's Profile: http://www.excelforum.com/member.php?

action=getinfo&userid=5620
View this thread:

http://www.excelforum.com/showthread...hreadid=261510

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Draw Buttons

hi,

try something like this:
CommandButton1.Picture = _
LoadPicture("c:\windows\argyle.bmp")

-----Original Message-----

Hi Dave,
Thanks for all the help.( Same to you, ste mac :) ).
What I would like is to write code that, like the buttons

code :

Sub testme()

Dim myRng As Range
Dim myCell As Range
Dim wks As Worksheet
Dim myBTN As Button

Set wks = ActiveSheet
With wks
.Buttons.Delete 'remove existing buttons???
Set myRng = .Range("a1:a10")
For Each myCell In myRng.Cells
With myCell
Set myBTN = .Parent.Buttons.Add(0, 0, 0, 0)
myBTN.Name = "BTN_" & .Address(0, 0)
myBTN.OnAction = ThisWorkbook.Name & "!myBTNmacro"
myBTN.Caption = "Click Me"
End With
Next myCell
End With
End Sub

Except that I would like the button to look like an image

file. Is
there a property like myBtn.Image or something like that?

Or do I have
to add an image that is clickable? If so, how do I do it ?


--
junx13


----------------------------------------------------------

--------------
junx13's Profile: http://www.excelforum.com/member.php?

action=getinfo&userid=5620
View this thread:

http://www.excelforum.com/showthread...hreadid=261510

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Draw Buttons

I'd just use the picture. All of the cells get the same picture?

Option Explicit
Sub testme()

Dim myRng As Range
Dim myCell As Range
Dim wks As Worksheet
Dim myPict As Picture
Dim myPictName As String

myPictName = "C:\My Documents\My Pictures\clouds.jpg"

Set wks = ActiveSheet
With wks
.Pictures.Delete 'remove existing pictures???
Set myRng = .Range("a1:a10")
For Each myCell In myRng.Cells
With myCell
Set myPict = .Parent.Pictures.Insert(myPictName)
myPict.Height = .Height
myPict.Width = .Width
myPict.Left = .Left
myPict.Top = .Top
myPict.Name = "Pict_" & .Address(0, 0)
myPict.OnAction = ThisWorkbook.Name & "!myPictmacro"
End With
Next myCell
End With
End Sub
Sub myPictMacro()
Dim myPict As Picture

Set myPict = ActiveSheet.Pictures(Application.Caller)
With myPict
MsgBox .TopLeftCell.Address(0, 0) & vbLf & .Name
End With

End Sub


You could even set up an array of picture names and cycle through them.

junx13 wrote:

Hi Dave,
Thanks for all the help.( Same to you, ste mac :) ).
What I would like is to write code that, like the buttons code :

Sub testme()

Dim myRng As Range
Dim myCell As Range
Dim wks As Worksheet
Dim myBTN As Button

Set wks = ActiveSheet
With wks
Buttons.Delete 'remove existing buttons???
Set myRng = .Range("a1:a10")
For Each myCell In myRng.Cells
With myCell
Set myBTN = .Parent.Buttons.Add(0, 0, 0, 0)
myBTN.Name = "BTN_" & .Address(0, 0)
myBTN.OnAction = ThisWorkbook.Name & "!myBTNmacro"
myBTN.Caption = "Click Me"
End With
Next myCell
End With
End Sub

Except that I would like the button to look like an image file. Is
there a property like myBtn.Image or something like that? Or do I have
to add an image that is clickable? If so, how do I do it ?

--
junx13

------------------------------------------------------------------------
junx13's Profile: http://www.excelforum.com/member.php...fo&userid=5620
View this thread: http://www.excelforum.com/showthread...hreadid=261510


--

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
have toggle buttons but everytime print preview buttons move TinSandhu Excel Discussion (Misc queries) 1 October 11th 06 02:57 PM
Draw Buttons junx13[_13_] Excel Programming 2 September 21st 04 01:57 PM
Draw Buttons junx13[_12_] Excel Programming 1 September 21st 04 03:26 AM
Draw Buttons junx13[_10_] Excel Programming 2 September 21st 04 12:23 AM
Control Buttons vs. Command Buttons Robert Gibson Excel Programming 1 October 13th 03 04:33 PM


All times are GMT +1. The time now is 09:21 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"