LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Copy range Cell text and font properties to a Textbox

I have a spreadsheet cell that I would like to copy not only it's text but
it's Font properties to a textbox object. Since a single cell could have
several different font attributes per each character, how do you accomplish
this without setting each character's font one by one.

Hopefully there is a better way!!!!

---------------------------------------------------------------------
Example code looks like (if needed):

Place some text into A1 on a spreadsheet and change some font attributes
(i.e. bold, size, boldness, color...) on some of the letters in the text.
Add a textbox somewhere on the page (don't change the name, it should
default to "Text Box 1").

Below is the code:

Option Explicit
Sub TryIt()

Dim i As Integer, acell As Range, tb As TextBox, f As Font

Set acell = ActiveSheet.Range("A1")
Set tb = ActiveSheet.TextBoxes("Text Box 1")

'--- copy the text
tb.Text = acell.Text

'--- copy the font attributes one-by-one.... ugggg!!!!
For i = 1 To acell.Characters.Count

Set f = acell.Characters(i, 1).Font

With tb.Characters(i, 1).Font
.Bold = f.Bold
.Color = f.Color
.ColorIndex = f.ColorIndex
.FontStyle = f.FontStyle
.Italic = f.Italic
.Name = f.Name
.OutlineFont = f.OutlineFont
.Shadow = f.Shadow
.Size = f.Size
.Strikethrough = f.Strikethrough
.Subscript = f.Subscript
.Superscript = f.Superscript
.Underline = f.Underline
End With

Next

End Sub


 
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
textBox font colour the same as cell font colour???????? Sophie Excel Discussion (Misc queries) 4 February 13th 09 10:15 AM
copy cell font colour to textbox? Sophie Excel Discussion (Misc queries) 0 January 28th 09 01:03 AM
Copy/paste text in cells into a textbox ian123[_40_] Excel Programming 1 January 5th 04 11:03 PM
How to copy text from a TextBox in a ActiveSheet to a variable Tom Ogilvy Excel Programming 2 August 19th 03 06:35 PM
How to copy text from a TextBox in a ActiveSheet to a variable pat Excel Programming 0 August 19th 03 05:06 PM


All times are GMT +1. The time now is 09:47 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"