LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Naming objects on creation

And you really don't even need the object variable:

With ActiveSheet.Buttons.Add(174.75, 172.5, 157.5, 39)
.Name = "BTN_" & .TopLeftCell.Address(0, 0)
End With

or

ActiveSheet.Buttons.Add(174.75, 172.5, 157.5, 39).Name = "BTN_1"

though using the variables may make subsequent references easier.

In article ,
Dave Peterson wrote:

This worked ok for me:

Option Explicit
Sub testme01()

Dim OLEObj As OLEObject

Set OLEObj = ActiveSheet.OLEObjects.Add _
(ClassType:="Forms.CommandButton.1", _
Link:=False, DisplayAsIcon:=False, _
Left:=192.75, Top:=57.75, Width:=201.75, _
Height:=54)

With OLEObj
.Name = "CMDBTN_" & .TopLeftCell.Address(0, 0)
End With

'-------

Dim myBTN As Button

Set myBTN = ActiveSheet.Buttons.Add(174.75, 172.5, 157.5, 39)
With myBTN
.Name = "BTN_" & .TopLeftCell.Address(0, 0)
End With

End Sub

 
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
Creation Date Russell Burnett Excel Discussion (Misc queries) 0 December 4th 10 11:52 AM
CALENDAR CREATION gATOR gIRL Excel Discussion (Misc queries) 1 February 16th 10 10:02 AM
Macro creation Ojunera Excel Worksheet Functions 0 October 6th 08 06:28 PM
Table creation help please Dave Excel Worksheet Functions 1 March 11th 07 10:05 PM
Naming objects Iain Excel Discussion (Misc queries) 1 April 19th 05 09:25 AM


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