What's wrong with this?

S

sarndt

In VBA Code behind a worksheet

Dim objFrame As OleObject
Dim objTextBox As OLEObject

Set objFrame = ActiveSheet.OLEObjects.Add(ClassType:="Forms.Frame.1")
Set objTextBox =
ActiveSheet.OLEObjects(objFrame).Add(ClassType:="Forms.Textbox.1")

Frame is created. But Textbox statement errors out - and doesn't get
created inside of Frame

Thanks

Steve
 
R

Rick Rothstein

The Forms Toolbar does not have a TextBox control on it... you will need to
use either the one from the Drawing Toolbar or from the Control Toolbox
Toolbar instead.
 
S

sarndt

Rick

Thanks for the info. Everytime I try to use the MSForms.Frame and Textbox,
I get the Cannot Install Object error. I've tried various recommendations
from the Internet to fix the problem but none have worked so far. I keep
working on it.

Steve
 
S

sarndt

Well - I've played with this further. I can add a control toolbox frame to
the worksheet in display mode, but I can't add it using the code below in the
Worksheet_change event where I trying to add the frame.

Set objFrame = Activesheet.OLEObjects.Add(classtype:="MSForms.Frame")

Steve

=================
 
W

witek

Try this


Dim objFrame As Frame
Dim objTextBox As Control

Set objFrame = ActiveSheet.OLEObjects.Add(ClassType:="Forms.Frame.1").Object
Set objTextBox = objFrame.Controls.Add("Forms.Textbox.1")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top