Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.basic.visual.misc > #97
| Date | 2011-04-24 12:51 -0400 |
|---|---|
| Newsgroups | comp.lang.basic.visual.misc |
| Organization | RDP |
| Message-Id | <VA.000001cd.b50ab3dc@rdpslides.com> |
| Subject | Re: VB6 to Excel |
| From | Steve Rindsberg <steve@rdpslides.com> |
| References | <aiUsp.26$2z7.14@newsfe15.ams2> <ip194v$a7k$1@dont-email.me> |
> With xlSheet
> .Shapes.AddFormControl xlButtonControl, 100, 100, 100, 100
> With .Shapes(1)
> 'Control must be selected to edit text
> .Select: Selection.Characters.Text = "ButtonCaption"
> .OnAction = "MacroName"
> End With
> .Cells(1).Select 'exit edit text mode
> End With
I'd do this instead:
' Set up a variable to hold a reference to the shape
' you're going to create:
Dim oSh as Shape
With xlSheet
' create the shape and get a ref to it
Set oSh = .Shapes.AddFormControl( xlButtonControl, 100, 100, 100, 100)
' now you can work with the shape
' and don't have to rely on it being the first shape on the sheet
With oSh
'Control must be selected to edit text
.Select: Selection.Characters.Text = "ButtonCaption"
.OnAction = "MacroName"
End With
.Cells(1).Select 'exit edit text mode
End With
You can also avoid selecting it if you do this:
With oSh.OLEFormat.Object
.Caption = "Your Text Here"
End With
And inside that With/End With context you can work with any of the other
properties you'd normally see when you rightclick/Properties. Intellisense
won't help you but the Properties dialog will give you the names of the
available properties.
Back to comp.lang.basic.visual.misc | Previous | Next — Previous in thread | Next in thread | Find similar
VB6 to Excel "Ivar" <ivar.ekstromer000@ntlworld.com> - 2011-04-24 13:01 +0100
Re: VB6 to Excel GS <gs@somewhere.net> - 2011-04-24 09:40 -0400
Re: VB6 to Excel "Ivar" <ivar.ekstromer000@ntlworld.com> - 2011-04-24 16:04 +0100
Re: VB6 to Excel ralph <nt_consulting64@yahoo.net> - 2011-04-24 10:54 -0500
Re: VB6 to Excel GS <gs@somewhere.net> - 2011-04-24 12:28 -0400
Re: VB6 to Excel GS <gs@somewhere.net> - 2011-04-24 14:58 -0400
Re: VB6 to Excel Steve Rindsberg <steve@rdpslides.com> - 2011-04-24 12:51 -0400
Re: VB6 to Excel GS <gs@somewhere.net> - 2011-04-24 13:44 -0400
Re: VB6 to Excel ralph <nt_consulting64@yahoo.net> - 2011-04-24 12:23 -0500
Re: VB6 to Excel ralph <nt_consulting64@yahoo.net> - 2011-04-24 12:30 -0500
Re: VB6 to Excel Steve Rindsberg <steve@rdpslides.com> - 2011-04-25 15:57 -0400
Re: VB6 to Excel GS <gs@somewhere.net> - 2011-04-25 16:38 -0400
Re: VB6 to Excel Steve Rindsberg <steve@rdpslides.com> - 2011-04-26 19:54 -0400
Re: VB6 to Excel GS <gs@somewhere.net> - 2011-04-26 23:06 -0400
csiph-web