creating VBA runtime controls 
Author Message
 creating VBA runtime controls

On a project I'm currently working on I need to be able
to dynamically create labels on an Excel spreadsheet.  
I've tried using the Add method in VBA, ex.    
Me.Controls.Add "Forms.Label.1", "Label" & intCounter.  
But I always get an error that says the method isn't
recognized.  Any help on this would be great.  Thanks in
advance.


Tue, 12 Oct 2004 22:42:19 GMT  
 creating VBA runtime controls
ActiveSheet.OLEObjects.Add(ClassType:="Forms.Label.1", ....

Luc


Quote:
> On a project I'm currently working on I need to be able
> to dynamically create labels on an Excel spreadsheet.
> I've tried using the Add method in VBA, ex.
> Me.Controls.Add "Forms.Label.1", "Label" & intCounter.
> But I always get an error that says the method isn't
> recognized.  Any help on this would be great.  Thanks in
> advance.



Tue, 12 Oct 2004 23:09:04 GMT  
 creating VBA runtime controls
Luc thanks for the quick reply.  I tried the line you
gave me and I keep getting a compile error that
reads "expected:=".  What else do I need after I type
ActiveSheet.OLEObjects.Add(ClassType:="Forms.Label.1",

I tried typing in the name I'd like to call the new
label, either that's not what I'm suppose to type or I
need more for the code to work.  Thanks again.

Scott

Quote:
>-----Original Message-----
>ActiveSheet.OLEObjects.Add

(ClassType:="Forms.Label.1", ....
Quote:

>Luc



>> On a project I'm currently working on I need to be able
>> to dynamically create labels on an Excel spreadsheet.
>> I've tried using the Add method in VBA, ex.
>> Me.Controls.Add "Forms.Label.1", "Label" & intCounter.
>> But I always get an error that says the method isn't
>> recognized.  Any help on this would be great.  Thanks
in
>> advance.

>.



Tue, 12 Oct 2004 23:23:26 GMT  
 creating VBA runtime controls
the whole line could look like this:

Set myLabel = ActiveSheet.OLEObjects.Add(ClassType:="Forms.Label.1",
Link:=False, _
           DisplayAsIcon:=False, Left:=150, Top:=90, Width:=72, Height:=18)

To get more information about the parameters move your cursor in your excel
code over 'OLEObjects' and press F1. In particular the information about the
'add' method.

Do you know how to record macros? Often this is an easy first step to get
some sample code.

Luc


Quote:
> Luc thanks for the quick reply.  I tried the line you
> gave me and I keep getting a compile error that
> reads "expected:=".  What else do I need after I type
> ActiveSheet.OLEObjects.Add(ClassType:="Forms.Label.1",

> I tried typing in the name I'd like to call the new
> label, either that's not what I'm suppose to type or I
> need more for the code to work.  Thanks again.

> Scott
> >-----Original Message-----
> >ActiveSheet.OLEObjects.Add
> (ClassType:="Forms.Label.1", ....

> >Luc



> >> On a project I'm currently working on I need to be able
> >> to dynamically create labels on an Excel spreadsheet.
> >> I've tried using the Add method in VBA, ex.
> >> Me.Controls.Add "Forms.Label.1", "Label" & intCounter.
> >> But I always get an error that says the method isn't
> >> recognized.  Any help on this would be great.  Thanks
> in
> >> advance.

> >.



Tue, 12 Oct 2004 23:37:37 GMT  
 creating VBA runtime controls
Nevermind I figured it out, thanks for the help again.

Scott

Quote:
>-----Original Message-----
>Luc thanks for the quick reply.  I tried the line you
>gave me and I keep getting a compile error that
>reads "expected:=".  What else do I need after I type
>ActiveSheet.OLEObjects.Add(ClassType:="Forms.Label.1",

>I tried typing in the name I'd like to call the new
>label, either that's not what I'm suppose to type or I
>need more for the code to work.  Thanks again.

>Scott
>>-----Original Message-----
>>ActiveSheet.OLEObjects.Add
>(ClassType:="Forms.Label.1", ....

>>Luc



>>> On a project I'm currently working on I need to be
able
>>> to dynamically create labels on an Excel spreadsheet.
>>> I've tried using the Add method in VBA, ex.
>>> Me.Controls.Add "Forms.Label.1", "Label" & intCounter.
>>> But I always get an error that says the method isn't
>>> recognized.  Any help on this would be great.  Thanks
>in
>>> advance.

>>.

>.



Tue, 12 Oct 2004 23:41:23 GMT  
 creating VBA runtime controls
I figured it out right after I posted that last message.  
Thanks for your time, I appreciated it.  

Scott

Quote:
>-----Original Message-----
>the whole line could look like this:

>Set myLabel = ActiveSheet.OLEObjects.Add

(ClassType:="Forms.Label.1",
Quote:
>Link:=False, _
>           DisplayAsIcon:=False, Left:=150, Top:=90,

Width:=72, Height:=18)
Quote:

>To get more information about the parameters move your

cursor in your excel
Quote:
>code over 'OLEObjects' and press F1. In particular the

information about the
Quote:
>'add' method.

>Do you know how to record macros? Often this is an easy
first step to get
>some sample code.

>Luc



>> Luc thanks for the quick reply.  I tried the line you
>> gave me and I keep getting a compile error that
>> reads "expected:=".  What else do I need after I type
>> ActiveSheet.OLEObjects.Add(ClassType:="Forms.Label.1",

>> I tried typing in the name I'd like to call the new
>> label, either that's not what I'm suppose to type or I
>> need more for the code to work.  Thanks again.

>> Scott
>> >-----Original Message-----
>> >ActiveSheet.OLEObjects.Add
>> (ClassType:="Forms.Label.1", ....

>> >Luc



>> >> On a project I'm currently working on I need to be
able
>> >> to dynamically create labels on an Excel
spreadsheet.
>> >> I've tried using the Add method in VBA, ex.
>> >> Me.Controls.Add "Forms.Label.1", "Label" &
intCounter.
>> >> But I always get an error that says the method isn't
>> >> recognized.  Any help on this would be great.  
Thanks
>> in
>> >> advance.

>> >.

>.



Tue, 12 Oct 2004 23:43:02 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Creating controls on forms at runtime in VBA

2. Creating controls at runtime & Control arrays

3. Creating Controls at runtime & Control Arrays

4. How to create and place controls at runtime into Tabbed Dialog Control of Videosoft or Microsoft

5. Creating dynamic / runtime controls in control array

6. How to create and place controls at runtime into Tabbed Dialog Control of Videosoft or Microsoft

7. Creating ActiveX Controls at Runtime using a Control Array

8. loading controls at runtime in VBA?

9. Runtime Controls in Word-VBA

10. Adding Controls at Runtime and Trapping Events with VBA

11. Creating Controls At Runtime

12. Creating a commandbar control at runtime

 

 
Powered by phpBB® Forum Software