PC Review


Reply
Thread Tools Rate Thread

how can I work with worksheet textboxes in VBA?

 
 
Pat D
Guest
Posts: n/a
 
      20th Mar 2008
I have several textboxes on an Excel worksheet. Is there a way to access
(change contents, formatting,...) these textboxes from within my VBA code?
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      20th Mar 2008
Using the control from the Controls Toolbox:

Sub txtbx()
Sheets(1).TextBox1.Text = "Hello"
MsgBox Sheets(1).TextBox1.Text
Sheets(1).TextBox1.Font.Italic = True
Sheets(1).TextBox1.Text = ""
End Sub


"Pat D" wrote:

> I have several textboxes on an Excel worksheet. Is there a way to access
> (change contents, formatting,...) these textboxes from within my VBA code?

 
Reply With Quote
 
Pat D
Guest
Posts: n/a
 
      20th Mar 2008
I should've clarified a bit more...
what you are saying is workable for ActiveX or Form Controls.
I am referring to a textbox from the Insert menu (Office 2007).
The reason why I am using a plain text box is that I need to include a
bullet list in the text box, but I want to be able to alter the contents of
the bulleted list from my VBA code...

"JLGWhiz" wrote:

> Using the control from the Controls Toolbox:
>
> Sub txtbx()
> Sheets(1).TextBox1.Text = "Hello"
> MsgBox Sheets(1).TextBox1.Text
> Sheets(1).TextBox1.Font.Italic = True
> Sheets(1).TextBox1.Text = ""
> End Sub
>
>
> "Pat D" wrote:
>
> > I have several textboxes on an Excel worksheet. Is there a way to access
> > (change contents, formatting,...) these textboxes from within my VBA code?

 
Reply With Quote
 
Ken Johnson
Guest
Posts: n/a
 
      20th Mar 2008
On Mar 20, 10:46 pm, Pat D <Pat D...@discussions.microsoft.com> wrote:
> I have several textboxes on an Excel worksheet. Is there a way to access
> (change contents, formatting,...) these textboxes from within my VBA code?


Text boxes are Shape objects.

Examples:
ActiveSheet.Shapes("Text Box 1").TextFrame.Characters.Text =
ActiveSheet.Shapes("Text Box 1").TextFrame.Characters.Text & Chr(10) &
"That's all folks."

Adds a new line and "That's all folk." to Text Box 1

ActiveSheet.Shapes("Text Box 1").TextFrame.Characters(20,
25).Font.Bold = True

Makes 25 characters, starting at the 20th character, Bold.

Ken Johnson
 
Reply With Quote
 
Pat D
Guest
Posts: n/a
 
      20th Mar 2008
Thanks!

"Ken Johnson" wrote:

> On Mar 20, 10:46 pm, Pat D <Pat D...@discussions.microsoft.com> wrote:
> > I have several textboxes on an Excel worksheet. Is there a way to access
> > (change contents, formatting,...) these textboxes from within my VBA code?

>
> Text boxes are Shape objects.
>
> Examples:
> ActiveSheet.Shapes("Text Box 1").TextFrame.Characters.Text =
> ActiveSheet.Shapes("Text Box 1").TextFrame.Characters.Text & Chr(10) &
> "That's all folks."
>
> Adds a new line and "That's all folk." to Text Box 1
>
> ActiveSheet.Shapes("Text Box 1").TextFrame.Characters(20,
> 25).Font.Bold = True
>
> Makes 25 characters, starting at the 20th character, Bold.
>
> Ken Johnson
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tab Function for textboxes on Worksheet not UserForm LRay67 Microsoft Excel Programming 1 11th Mar 2008 04:27 PM
Managing Textboxes in a Worksheet =?Utf-8?B?UGhpbCBI?= Microsoft Excel Programming 4 3rd May 2006 06:55 AM
Textboxes on a worksheet Ian Collard Microsoft Excel Programming 2 4th May 2004 05:00 PM
Updating Worksheet from Userform TextBoxes Alan T Microsoft Excel Misc 2 23rd Jan 2004 03:16 PM
how do I link Textboxes in a userform to a Cell in a Worksheet? =?Utf-8?B?UGF1bCBDbGFyaw==?= Microsoft Excel Programming 2 17th Jan 2004 05:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:45 PM.