Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Underline font not reporting properly

I would like to hear from other individuals who either have experienced this
issue and/or have resolved the issue.

When I am running the Excel automation process, I cannot accurately
determine if a cell has the Underline font set (See the code below). I have
extracted the code and structured it in such a way to illustrate the issue I
have discovered.

The problem is: Excel reports back that the cell DOES have the underline
font set even though it is not set (i.e. value returned is TRUE).

I am running this code from Access (2000 or higher).

Your input/assistance is appreciated.
Rob



Test Code
----------------------
Private m_Excel As Excel.Application
Private m_Workbook As Excel.Workbook
Private m_ActiveSheet As Excel.Worksheet

' Make sure that you set the references to either Excel 2000, 2002, or 2003
'
Public Sub TestUnderline()

Dim fValue As Boolean

Set m_Excel = New Excel.Application
m_Excel.Visible = True

Set m_Workbook = m_Excel.Workbooks.Add
Set m_ActiveSheet = m_Workbook.ActiveSheet

' Put some value in the cell
m_ActiveSheet.Range("A1").Value = "ABC123"

' Determine if the underline font has been set
fValue = m_ActiveSheet.Range("A1").Font.Underline

' Display the results
MsgBox Prompt:=fValue, Title:="Is the font 'Underline' set for the cell?"

m_Workbook.Close SaveChanges:=0

m_Excel.Quit

Set m_Excel = Nothing

End Sub


--
Rob

FMS Professional Solutions Group
http://www.fmsinc.com/consulting

Software Tools for .NET, SQL Server, Visual Basic & Access
http://www.fmsinc.com

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Underline font not reporting properly

Try declaring fValue as a Long.

You'll see that you get -4142 back -- by coercing this value into a boolean,
you're getting a True (non-zero).

The .underline can be
xlUnderlineStyleNone
xlUnderlineStyleSingle
xlUnderlineStyleDouble
xlUnderlineStyleSingleAccounting
xlUnderlineStyleDoubleAccounting

And if you open up the immediate window and type:
?xlunderlinestylenone
you'll see:
-4142

If you want:

m_ActiveSheet.Range("A1").Value = "ABC123"
m_ActiveSheet.Range("A1").font.underline = xlunderlinestyleSingle ' =2

Then try it.



RobFMS wrote:

I would like to hear from other individuals who either have experienced this
issue and/or have resolved the issue.

When I am running the Excel automation process, I cannot accurately
determine if a cell has the Underline font set (See the code below). I have
extracted the code and structured it in such a way to illustrate the issue I
have discovered.

The problem is: Excel reports back that the cell DOES have the underline
font set even though it is not set (i.e. value returned is TRUE).

I am running this code from Access (2000 or higher).

Your input/assistance is appreciated.
Rob

Test Code
----------------------
Private m_Excel As Excel.Application
Private m_Workbook As Excel.Workbook
Private m_ActiveSheet As Excel.Worksheet

' Make sure that you set the references to either Excel 2000, 2002, or 2003
'
Public Sub TestUnderline()

Dim fValue As Boolean

Set m_Excel = New Excel.Application
m_Excel.Visible = True

Set m_Workbook = m_Excel.Workbooks.Add
Set m_ActiveSheet = m_Workbook.ActiveSheet

' Put some value in the cell
m_ActiveSheet.Range("A1").Value = "ABC123"

' Determine if the underline font has been set
fValue = m_ActiveSheet.Range("A1").Font.Underline

' Display the results
MsgBox Prompt:=fValue, Title:="Is the font 'Underline' set for the cell?"

m_Workbook.Close SaveChanges:=0

m_Excel.Quit

Set m_Excel = Nothing

End Sub

--
Rob

FMS Professional Solutions Group
http://www.fmsinc.com/consulting

Software Tools for .NET, SQL Server, Visual Basic & Access
http://www.fmsinc.com

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


--

Dave Peterson

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
Borders nor underline commands remove an unusual underline. ?? VideoFreak Excel Discussion (Misc queries) 4 February 11th 06 08:17 PM
Strikethrough and Underline Font Macro Rainman Excel Worksheet Functions 0 August 9th 05 01:32 PM
ACAD does not display Technic font properly in office 2003-why? SLO Kermit Excel Discussion (Misc queries) 1 February 26th 05 01:14 PM
Unable to set Underline property of the Font class PF[_3_] Excel Programming 0 April 8th 04 09:11 PM
Changing font size, bold and underline ChuckM[_2_] Excel Programming 1 December 17th 03 02:12 PM


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