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 to format text in a Text box using VBA code


Hi All,

I have just started using VBA so this might be an easy question but
have been unable to find an answer so far in my searches.

I have created a text box and added text to it, even changed th
background colour all using VBA code. However I am unable to chang
the font bold, text size, and alignment using VBA code for the tex
box.

Can anyone help?

Also another question off the main topic, does anyone know how to tur
the "snap to grid" option on and off using VBA code in excel?

I am using Excel 97, its on a work computer and they have not upgrade
yet.

Any information would be greatly appreciated.

Thank you and hace a nice day.
Shane

--
Shane
-----------------------------------------------------------------------
Shane B's Profile: http://www.excelforum.com/member.php...fo&userid=1646
View this thread: http://www.excelforum.com/showthread.php?threadid=27820

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to format text in a Text box using VBA code

In a textbox from the control toolbox toolbar, you don't - it isn't
supported. A textbox from the Forms toolbar, use the characters method.

For both questions, turn on the macro recorder and do it manually. Then
stop the recorder and look at the recorded code. This will give you great
insight into how to do it with VBA code.

--
Regards,
Tom Ogilvy

"Shane B" wrote in message
...

Hi All,

I have just started using VBA so this might be an easy question but I
have been unable to find an answer so far in my searches.

I have created a text box and added text to it, even changed the
background colour all using VBA code. However I am unable to change
the font bold, text size, and alignment using VBA code for the text
box.

Can anyone help?

Also another question off the main topic, does anyone know how to turn
the "snap to grid" option on and off using VBA code in excel?

I am using Excel 97, its on a work computer and they have not upgraded
yet.

Any information would be greatly appreciated.

Thank you and hace a nice day.
Shane B


--
Shane B
------------------------------------------------------------------------
Shane B's Profile:

http://www.excelforum.com/member.php...o&userid=16467
View this thread: http://www.excelforum.com/showthread...hreadid=278207



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default How to format text in a Text box using VBA code

Hi,
I did this on record new macro.
Range("A1").Select
With Selection.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With

-----Original Message-----

Hi All,

I have just started using VBA so this might be an easy

question but I
have been unable to find an answer so far in my searches.

I have created a text box and added text to it, even

changed the
background colour all using VBA code. However I am

unable to change
the font bold, text size, and alignment using VBA code

for the text
box.

Can anyone help?

Also another question off the main topic, does anyone

know how to turn
the "snap to grid" option on and off using VBA code in

excel?

I am using Excel 97, its on a work computer and they have

not upgraded
yet.

Any information would be greatly appreciated.

Thank you and hace a nice day.
Shane B


--
Shane B
----------------------------------------------------------

--------------
Shane B's Profile: http://www.excelforum.com/member.php?

action=getinfo&userid=16467
View this thread:

http://www.excelforum.com/showthread...hreadid=278207

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to format text in a Text box using VBA code

Let me qualify my answer a little - I assumed you were doing Rich Text
Formats, but after rereading, that is not necessarily a valid assumption.
For a control toolbox toolbar textbox you can do:

Sub Macro3()
ActiveSheet.TextBox2.Font.Bold = False
ActiveSheet.TextBox2.Font.Size = 13
End Sub

for bold and size. for alignment, I don't think it is supported.

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
In a textbox from the control toolbox toolbar, you don't - it isn't
supported. A textbox from the Forms toolbar, use the characters method.

For both questions, turn on the macro recorder and do it manually. Then
stop the recorder and look at the recorded code. This will give you great
insight into how to do it with VBA code.

--
Regards,
Tom Ogilvy

"Shane B" wrote in message
...

Hi All,

I have just started using VBA so this might be an easy question but I
have been unable to find an answer so far in my searches.

I have created a text box and added text to it, even changed the
background colour all using VBA code. However I am unable to change
the font bold, text size, and alignment using VBA code for the text
box.

Can anyone help?

Also another question off the main topic, does anyone know how to turn
the "snap to grid" option on and off using VBA code in excel?

I am using Excel 97, its on a work computer and they have not upgraded
yet.

Any information would be greatly appreciated.

Thank you and hace a nice day.
Shane B


--
Shane B
------------------------------------------------------------------------
Shane B's Profile:

http://www.excelforum.com/member.php...o&userid=16467
View this thread:

http://www.excelforum.com/showthread...hreadid=278207





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
Text format - setting text colour with code NDBC Excel Discussion (Misc queries) 6 July 1st 09 10:15 PM
using a conditional suffix in text function format syntax=text(value,format_text) Brotherharry Excel Worksheet Functions 1 January 13th 09 03:03 PM
remove text with format code for phone numbers Jan Excel Discussion (Misc queries) 4 November 12th 08 02:03 PM
Macro - Fixed text code needs replacing with variable text steven.holloway Excel Discussion (Misc queries) 3 July 22nd 08 03:57 PM
code to convert date from TEXT format (03-02) to DATE format (200203) Gauthier[_2_] Excel Programming 0 September 22nd 04 03:26 PM


All times are GMT +1. The time now is 02:24 PM.

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

About Us

"It's about Microsoft Excel"