LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 146
Default creating/manipulating form controls placed on a spreadsheet inexcel using vba

A similar approach to adding the control is AddFormControl:

Sub AddButton()
Dim myButton As Shape
Set myButton = ActiveSheet.Shapes.AddFormControl _
(xlButtonControl, 100, 10, 100, 20)
With myButton
.Name = "My Button"
.TextFrame.Characters.Text = "Click Me"
.OnAction = "MyMacro"
End With
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


Chip Pearson wrote:

The following code will create a command button on the active
sheet and create an event procedure for that command button:

Dim OLEObj As OLEObject
Dim LineNum As Long

Set OLEObj =
ActiveSheet.OLEObjects.Add(classtype:="Forms.Comma ndButton.1")
With OLEObj
.Top = Range("C3").Top
.Left = Range("C3").Left
.Width = Range("C3").Width
.Height = Range("C3").Height
.Name = "MyButton"
With .Object
.Caption = "Click Me"
End With
End With

With ThisWorkbook.VBProject.VBComponents("Sheet1").Code Module
LineNum = .CreateEventProc("Click", "MyButton")
.InsertLines LineNum + 1, "Msgbox ""Hello World"""
End With



 
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
saving a spreadsheet with form controls ld Excel Worksheet Functions 0 February 24th 10 03:42 PM
Form controls in Excel 07 New to Excel 07 Excel Discussion (Misc queries) 1 July 30th 07 04:43 PM
Creating controls to autofill a form wepstech Excel Discussion (Misc queries) 2 February 23rd 07 01:00 PM
ActiveX Controls vs Form Controls Alex Excel Discussion (Misc queries) 1 January 11th 06 08:46 AM
Label, Text and Form controls in Excel 97 TomCee Excel Programming 1 April 20th 04 04:52 PM


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