Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I insert Text Box in ActiveCell


I'm trying to create a macro to insert a Text Box (Autoshape) in an
Active Cell.

I used the VBA macro recorder to create an initial macro, but have no
been able to have the text box placed in the active cell. I trie
modifying the code, but each time it places the text box in the area
originally recorded the macro. I'm a beginner.

Here is an example of the vba code without modification:

ActiveSheet.Shapes.AddShape(msoShapeRectangle, 222#, 69.75, 72#, 72#)
_
Select
Selection.ShapeRange.ScaleWidth 6.26, msoFalse
msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 0.97, msoFalse
msoScaleFromTopLeft
Selection.Characters.Text = ""
With Selection.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With

Thanks in advance. :

--
Bor
-----------------------------------------------------------------------
Borg's Profile: http://www.excelforum.com/member.php...fo&userid=3639
View this thread: http://www.excelforum.com/showthread.php?threadid=56175

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How do I insert Text Box in ActiveCell

I'd use something like:

Option Explicit
Sub testme01()

Dim myCell As Range
Dim myTextBox As TextBox

Set myCell = ActiveCell

With myCell
Set myTextBox = .Parent.TextBoxes.Add(Top:=.Top, Left:=.Left, _
Width:=.Width, Height:=.Height)
End With

With myTextBox
.Caption = "some stuff" 'if you want...
End With

End Sub

Borg wrote:

I'm trying to create a macro to insert a Text Box (Autoshape) in any
Active Cell.

I used the VBA macro recorder to create an initial macro, but have not
been able to have the text box placed in the active cell. I tried
modifying the code, but each time it places the text box in the area I
originally recorded the macro. I'm a beginner.

Here is an example of the vba code without modification:

ActiveSheet.Shapes.AddShape(msoShapeRectangle, 222#, 69.75, 72#, 72#).
_
Select
Selection.ShapeRange.ScaleWidth 6.26, msoFalse,
msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 0.97, msoFalse,
msoScaleFromTopLeft
Selection.Characters.Text = ""
With Selection.Font
Name = "Arial"
FontStyle = "Regular"
Size = 10
Strikethrough = False
Superscript = False
Subscript = False
OutlineFont = False
Shadow = False
Underline = xlUnderlineStyleNone
ColorIndex = xlAutomatic
End With

Thanks in advance. :)

--
Borg
------------------------------------------------------------------------
Borg's Profile: http://www.excelforum.com/member.php...o&userid=36396
View this thread: http://www.excelforum.com/showthread...hreadid=561752


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I insert Text Box in ActiveCell


Thanks! :)


--
Borg
------------------------------------------------------------------------
Borg's Profile: http://www.excelforum.com/member.php...o&userid=36396
View this thread: http://www.excelforum.com/showthread...hreadid=561752

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Echo Contents of ActiveCell into a Text box. ChrisR Excel Discussion (Misc queries) 2 September 17th 09 04:00 PM
If activecell.column = variable then activecell,offset (0,1) Battykoda via OfficeKB.com Excel Discussion (Misc queries) 1 October 2nd 07 08:05 PM
If activecell is not text John Excel Programming 1 January 27th 06 06:31 PM
Insert cell/format/text/fontsize and auto insert into header? Unfurltheflag Excel Programming 2 November 3rd 04 05:39 PM
insert row below activecell ljb[_2_] Excel Programming 2 November 14th 03 03:55 PM


All times are GMT +1. The time now is 04:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"