Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / May 2006

Tip: Looking for answers? Try searching our database.

Dymically add text box to form in Word Macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JUICE - 07 May 2006 20:00 GMT
Hi,
I was wondering if anyone could help. I am getting an "object required"
error on the following line of code:

Set ctlText = Controls.Add("VB.TextBox", "ctlText1")

I am initialising like so in the class module:

Dim WithEvents ctlText As VB.TextBox
Jezebel - 07 May 2006 23:49 GMT
The keyword 'Controls' is defined in both the Office and Forms libraries;
and the Office library normally takes precedence in the references list. So
the 'object required' -- in this case -- is the commandbar that owns the
controls collection.

Try: Me.Controls.Add(...)

> Hi,
> I was wondering if anyone could help. I am getting an "object required"
[quoted text clipped - 5 lines]
>
> Dim WithEvents ctlText As VB.TextBox
JUICE - 08 May 2006 22:12 GMT
Hi,
Thanks for your reply. I have tried
Set ctlText = Me.Controls.Add("VB.TextBox", "ctlText1")

and it has generated the error "invalid use of me keyword"
Jezebel - 08 May 2006 23:26 GMT
Is the line of code within a form? If not, instead of Me, you want a
reference to the form.

> Hi,
> Thanks for your reply. I have tried
> Set ctlText = Me.Controls.Add("VB.TextBox", "ctlText1")
>
> and it has generated the error "invalid use of me keyword"
Steve Macleod - 10 May 2006 20:59 GMT
ok, thanks for this.
I have attempted to use the form name:
genScriptfrm.Controls.Add("VB.TextBox", "ctlText1")
although this generates an "invalid class string" error.
The code is within a private sub. I am unsure if I must pass a
reference to the form in through the main sub that starts when the
macro is run.

Can anyone advise?

Many, thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.