+ Reply to Thread
Results 1 to 3 of 3

Text box with Arial 12 font

Hybrid View

Xx7 Text box with Arial 12 font 07-02-2011, 04:49 PM
Leith Ross Re: Text box with Arial 12... 07-02-2011, 07:10 PM
Xx7 Re: Text box with Arial 12... 07-05-2011, 03:59 PM
  1. #1
    Forum Contributor
    Join Date
    01-30-2011
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2010
    Posts
    604

    Text box with Arial 12 font

    Looking for a macro to create a text box with Arial 12 as the default font.
    Last edited by Xx7; 07-05-2011 at 04:00 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Text box with Arial 12 font

    Hello Xx7,

    This macro adds an ActiveX TextBox to a worksheet and aligns it with the cell you specify. The sheet does not have to be the active sheet for the macro to work.
    Sub AddTextBox(Rng As Range)
    
      Dim Height As Double
      Dim Left As Double
      Dim Top As Double
      Dim TxtBox As Object
      Dim Width As Double
      Dim Wks As Worksheet
      
        Set Wks = Rng.Parent
        
        Left = Rng.Left
        Top = Rng.Top
        Height = 22
        Width = 76
        
        Set TxtBox = Wks.OLEObjects.Add("Forms.TextBox.1", Left:=Left, Top:=Top, Width:=Width, Height:=Height)
        
        With TxtBox.Object
          .ForeColor = vbBlack
          .FontName = "Arial"
          .FontSize = 12
        End With
        
    End Sub

    Macro Example
    This adds a TextBox to "Sheet1" and places the upper left corner of the TextBox in cell "G15".
    Sub TestIt()
    
      AddTextBox Worksheets("Sheet1").Range("G15")
      
    End Sub
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    01-30-2011
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2010
    Posts
    604

    Re: Text box with Arial 12 font

    Works great!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1