LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 470
Default Syntax problem with code

Below is a macro I am testing. I am trying to create 26 command buttons,
starting with Commandbutton6, but a caption starting with number 1.
Something is wrong with the "Activesheet.OLEObject" line and I don't know
what.

Private Sub CommandButton2_Click()
Dim h, w, t, l As Long
Dim k As Integer
h = 21
w = 91.5
l = 50
t = 92
For k = 1 To 26
ActiveSheet.OLEObjects.Add(ClassType:="Forms.Comma ndButton." & k + 5,
Left = l, Top = t, Width = w, Height = h)
.Object.Caption = "Button " & k + 5
t = t + 38
If k = 7 Or k = 14 Or k = 20 Then
l = l + 145
t = 92
End If
Next k
End Sub

Can someone tell me what is wrong? Thanks

One other question. I have seen the syntax similar to what I show below.
If using this syntax, what is "newbutton" DIM as?

Set newbutton = Applicationsheet.OLEObject.Add(Forms.CommandButton ....)

Thanks,
Les
 
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
SendKeys syntax problem VBAvirgin New Users to Excel 2 January 4th 06 04:42 PM
.XValues syntax problem JF_01 Charts and Charting in Excel 1 December 19th 05 08:21 PM
VBA code to sum a row: syntax needed [email protected] Excel Discussion (Misc queries) 1 July 11th 05 06:41 PM
Syntax problem Alex H Excel Worksheet Functions 1 July 2nd 05 08:23 AM
syntax question - cell references in VB code needyourhelp New Users to Excel 1 March 2nd 05 08:52 PM


All times are GMT +1. The time now is 08:17 PM.

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"