Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 169
Default How to know which cell caracters are underlined

Hi!
I use VBA automation to apply table excel formatting into word. In this
program, all work except the Font.Underline.
bMixed = Cells(5,1).Characters(Start:=i, Length:=1).Font.Underline return
always true for any i if there's one underlined character in the cell.. Is
there a way to know which characters are underlined?
All other properties (bold, alignment, italic, superscript, etc. is correct)
Any idea?
Thank you!
Alex


With Range(Cells(iLine, jBegin), Cells(iLine, jBegin)) 'Word table range
.HorizontalAlignment =
ThisWorkbook.Sheets(SheetName).Range(sLoadData).Ho rizontalAlignment
.VerticalAlignment =
ThisWorkbook.Sheets(SheetName).Range(sLoadData).Ve rticalAlignment

For i = 1 To Len(.Value)
With .Characters(Start:=i, Length:=1).Font
.Bold =
ThisWorkbook.Sheets(SheetName).Range(sLoadData).Ch aracters(Start:=i,
Length:=1).Font.Bold
.Superscript =
ThisWorkbook.Sheets(SheetName).Range(sLoadData).Ch aracters(Start:=i,
Length:=1).Font.Superscript
.Subscript =
ThisWorkbook.Sheets(SheetName).Range(sLoadData).Ch aracters(Start:=i,
Length:=1).Font.Subscript
.Italic =
ThisWorkbook.Sheets(SheetName).Range(sLoadData).Ch aracters(Start:=i,
Length:=1).Font.Italic
.Underline =
ThisWorkbook.Sheets(SheetName).Range(sLoadData).Ch aracters(Start:=i,
Length:=1).Font.Underline 'THIS DOESN'T WORK
End With
Next i
--
Alex St-Pierre
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default How to know which cell caracters are underlined

It appears that there is more than one type of underline (single, double,
none), so the Underline property is not a Boolean value. Try this for a
general "is it underlined (either single or double)"...

bMixed = Cells(5,1).Characters(Start:=i, Length:=1).Font.Underline <
xlUnderlineStyleNone

Note: The above is supposed to be a single line statement (in case your
newsreader wraps it).

If you want to check for a specific kind of underline, the predefined
constants to check against appear to be xlUnderlineStyleSingle and
xlUnderlineStyleDouble.

Rick


"Alex St-Pierre" wrote in message
...
Hi!
I use VBA automation to apply table excel formatting into word. In this
program, all work except the Font.Underline.
bMixed = Cells(5,1).Characters(Start:=i, Length:=1).Font.Underline return
always true for any i if there's one underlined character in the cell.. Is
there a way to know which characters are underlined?
All other properties (bold, alignment, italic, superscript, etc. is
correct)
Any idea?
Thank you!
Alex


With Range(Cells(iLine, jBegin), Cells(iLine, jBegin)) 'Word table
range
.HorizontalAlignment =
ThisWorkbook.Sheets(SheetName).Range(sLoadData).Ho rizontalAlignment
.VerticalAlignment =
ThisWorkbook.Sheets(SheetName).Range(sLoadData).Ve rticalAlignment

For i = 1 To Len(.Value)
With .Characters(Start:=i, Length:=1).Font
.Bold =
ThisWorkbook.Sheets(SheetName).Range(sLoadData).Ch aracters(Start:=i,
Length:=1).Font.Bold
.Superscript =
ThisWorkbook.Sheets(SheetName).Range(sLoadData).Ch aracters(Start:=i,
Length:=1).Font.Superscript
.Subscript =
ThisWorkbook.Sheets(SheetName).Range(sLoadData).Ch aracters(Start:=i,
Length:=1).Font.Subscript
.Italic =
ThisWorkbook.Sheets(SheetName).Range(sLoadData).Ch aracters(Start:=i,
Length:=1).Font.Italic
.Underline =
ThisWorkbook.Sheets(SheetName).Range(sLoadData).Ch aracters(Start:=i,
Length:=1).Font.Underline 'THIS DOESN'T WORK
End With
Next i
--
Alex St-Pierre


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default How to know which cell caracters are underlined

If you want to check for a specific kind of underline, the predefined
constants to check against appear to be xlUnderlineStyleSingle and
xlUnderlineStyleDouble.


Actually, in addition to the above, there are two other predefined underline
constants available...xlUnderlineStyleSingleAccounting and
xlUnderlineStyleDoubleAccounting.

Rick

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default How to know which cell caracters are underlined

As Rick says the various Underline styles can be any of the following (from
help)

"Can be one of the following XlUnderlineStyle constants:
xlUnderlineStyleNone, xlUnderlineStyleSingle, xlUnderlineStyleDouble,
xlUnderlineStyleSingleAccounting, or xlUnderlineStyleDoubleAccounting.
Read/write Long."

When looking for potentially mixed formats start by reading to a Variant,
which can accept Null if mixed, eg (untested)

s = ""
v = cell.font.underline
if isnull(v) then
for i = 1 to len(cell)
s = s & iif(cell.characters(i,1).font.underline = xlNone,"o","x")
next
else
for i = 1 to len(cell)
if v = xlNone then s = s & "o" else s = s & "x"
next
end if

If you are using Late Binding change any xl constants to their intrinsic
values, eg for xlNone use -4142

Regards,
Peter T


"Alex St-Pierre" wrote in message
...
Hi!
I use VBA automation to apply table excel formatting into word. In this
program, all work except the Font.Underline.
bMixed = Cells(5,1).Characters(Start:=i, Length:=1).Font.Underline return
always true for any i if there's one underlined character in the cell.. Is
there a way to know which characters are underlined?
All other properties (bold, alignment, italic, superscript, etc. is

correct)
Any idea?
Thank you!
Alex


With Range(Cells(iLine, jBegin), Cells(iLine, jBegin)) 'Word table

range
.HorizontalAlignment =
ThisWorkbook.Sheets(SheetName).Range(sLoadData).Ho rizontalAlignment
.VerticalAlignment =
ThisWorkbook.Sheets(SheetName).Range(sLoadData).Ve rticalAlignment

For i = 1 To Len(.Value)
With .Characters(Start:=i, Length:=1).Font
.Bold =
ThisWorkbook.Sheets(SheetName).Range(sLoadData).Ch aracters(Start:=i,
Length:=1).Font.Bold
.Superscript =
ThisWorkbook.Sheets(SheetName).Range(sLoadData).Ch aracters(Start:=i,
Length:=1).Font.Superscript
.Subscript =
ThisWorkbook.Sheets(SheetName).Range(sLoadData).Ch aracters(Start:=i,
Length:=1).Font.Subscript
.Italic =
ThisWorkbook.Sheets(SheetName).Range(sLoadData).Ch aracters(Start:=i,
Length:=1).Font.Italic
.Underline =
ThisWorkbook.Sheets(SheetName).Range(sLoadData).Ch aracters(Start:=i,
Length:=1).Font.Underline 'THIS DOESN'T WORK
End With
Next i
--
Alex St-Pierre



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
how to extract caracters up to comma in excel cell jethan Excel Worksheet Functions 2 July 24th 08 01:54 PM
count the number of caracters in a cell Jan New Users to Excel 8 July 1st 06 01:10 AM
count the number of caracters in a cell Jan New Users to Excel 2 June 30th 06 09:32 PM
How can I detect if the text in a cell is underlined? plh Excel Programming 2 April 27th 06 02:42 AM
Can you Limit the number of caracters that can be typed in a cell? pepperjack[_3_] Excel Programming 3 August 29th 04 03:19 AM


All times are GMT +1. The time now is 09:50 AM.

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"