+ Reply to Thread
Results 1 to 4 of 4

Unable to Set Underline Property of Font Class

  1. #1
    Sherwood
    Guest

    Unable to Set Underline Property of Font Class

    Greetings,

    I'm not sure if I'm posting this to the correct newsgroup or not, so feel
    free to redirect me to the appropriate place if necessary. At any rate, I am
    receiving the error, "Unable to set the underline property of the font class"
    in an Access module using the Excel code below:

    ExcelSheet.Application.Cells(1, 1).Font.Underline = xlUnderlineStyleSingle

    The following line of code "does" work, however:

    ExcelSheet.Application.Cells(1, 1).Font.Bold = True

    Do you see anything wrong with the way I am attempting to set the underline
    property? Thanks in advance!
    --
    Sherwood

  2. #2
    K Dales
    Guest

    RE: Unable to Set Underline Property of Font Class

    I see nothing wrong with your code, assuming you have properly assigned the
    ExcelSheet object variable and you are properly pointing to the active
    worksheet. Possible issues:
    - Are you positive that the cell is unprotected at the time you are trying
    to make the change?
    - Is there anything else happening in the workbook at the time you are
    running that line of code that might have the sheet in a temporarily
    "uneditable" state?

    If you pause your code just before executing the troublesome line, what
    happens if you try typing both the .Underline=xlUnderlineStyleSingle and the
    ..Bold = True in the immediate pane? That way you know you are trying them
    under the exact same conditions. I would be surprised if you can set one
    font property but not the other under the exact same conditions.


    "Sherwood" wrote:

    > Greetings,
    >
    > I'm not sure if I'm posting this to the correct newsgroup or not, so feel
    > free to redirect me to the appropriate place if necessary. At any rate, I am
    > receiving the error, "Unable to set the underline property of the font class"
    > in an Access module using the Excel code below:
    >
    > ExcelSheet.Application.Cells(1, 1).Font.Underline = xlUnderlineStyleSingle
    >
    > The following line of code "does" work, however:
    >
    > ExcelSheet.Application.Cells(1, 1).Font.Bold = True
    >
    > Do you see anything wrong with the way I am attempting to set the underline
    > property? Thanks in advance!
    > --
    > Sherwood


  3. #3
    Sherwood
    Guest

    RE: Unable to Set Underline Property of Font Class

    I did type in the following line of code in the Immediate Pane and received
    the same error. I did check the cell ("A1") and it is definitely unprotected
    (this is a new worksheet that I am creating).

    ExcelSheet.Application.Cells(1, 1).Font.Underline = xlUnderlineStyleSingle

    What finally worked for me was using "True" instead of
    "xlUnderlineStyleSingle". This produced a single underline for the specified
    cell. Just wanted to let you know how I resolved it. Thanks again for your
    help.

    Sherwood

    "K Dales" wrote:

    > I see nothing wrong with your code, assuming you have properly assigned the
    > ExcelSheet object variable and you are properly pointing to the active
    > worksheet. Possible issues:
    > - Are you positive that the cell is unprotected at the time you are trying
    > to make the change?
    > - Is there anything else happening in the workbook at the time you are
    > running that line of code that might have the sheet in a temporarily
    > "uneditable" state?
    >
    > If you pause your code just before executing the troublesome line, what
    > happens if you try typing both the .Underline=xlUnderlineStyleSingle and the
    > .Bold = True in the immediate pane? That way you know you are trying them
    > under the exact same conditions. I would be surprised if you can set one
    > font property but not the other under the exact same conditions.
    >
    >
    > "Sherwood" wrote:
    >
    > > Greetings,
    > >
    > > I'm not sure if I'm posting this to the correct newsgroup or not, so feel
    > > free to redirect me to the appropriate place if necessary. At any rate, I am
    > > receiving the error, "Unable to set the underline property of the font class"
    > > in an Access module using the Excel code below:
    > >
    > > ExcelSheet.Application.Cells(1, 1).Font.Underline = xlUnderlineStyleSingle
    > >
    > > The following line of code "does" work, however:
    > >
    > > ExcelSheet.Application.Cells(1, 1).Font.Bold = True
    > >
    > > Do you see anything wrong with the way I am attempting to set the underline
    > > property? Thanks in advance!
    > > --
    > > Sherwood


  4. #4
    Peter T
    Guest

    Re: Unable to Set Underline Property of Font Class

    Hi Sherwood,

    XlUnderlineStyle is an Excel constant, a long 2. If you set a reference to
    Excel (vbe - tools - references) I suspect it should work. Otherwise just
    try the value 2.

    ExcelSheet.Application.etc. seems odd, but if it works...

    Regards,
    Peter T

    "Sherwood" <[email protected]> wrote in message
    news:[email protected]...
    > I did type in the following line of code in the Immediate Pane and

    received
    > the same error. I did check the cell ("A1") and it is definitely

    unprotected
    > (this is a new worksheet that I am creating).
    >
    > ExcelSheet.Application.Cells(1, 1).Font.Underline = xlUnderlineStyleSingle
    >
    > What finally worked for me was using "True" instead of
    > "xlUnderlineStyleSingle". This produced a single underline for the

    specified
    > cell. Just wanted to let you know how I resolved it. Thanks again for

    your
    > help.
    >
    > Sherwood
    >
    > "K Dales" wrote:
    >
    > > I see nothing wrong with your code, assuming you have properly assigned

    the
    > > ExcelSheet object variable and you are properly pointing to the active
    > > worksheet. Possible issues:
    > > - Are you positive that the cell is unprotected at the time you are

    trying
    > > to make the change?
    > > - Is there anything else happening in the workbook at the time you are
    > > running that line of code that might have the sheet in a temporarily
    > > "uneditable" state?
    > >
    > > If you pause your code just before executing the troublesome line, what
    > > happens if you try typing both the .Underline=xlUnderlineStyleSingle and

    the
    > > .Bold = True in the immediate pane? That way you know you are trying

    them
    > > under the exact same conditions. I would be surprised if you can set

    one
    > > font property but not the other under the exact same conditions.
    > >
    > >
    > > "Sherwood" wrote:
    > >
    > > > Greetings,
    > > >
    > > > I'm not sure if I'm posting this to the correct newsgroup or not, so

    feel
    > > > free to redirect me to the appropriate place if necessary. At any

    rate, I am
    > > > receiving the error, "Unable to set the underline property of the font

    class"
    > > > in an Access module using the Excel code below:
    > > >
    > > > ExcelSheet.Application.Cells(1, 1).Font.Underline =

    xlUnderlineStyleSingle
    > > >
    > > > The following line of code "does" work, however:
    > > >
    > > > ExcelSheet.Application.Cells(1, 1).Font.Bold = True
    > > >
    > > > Do you see anything wrong with the way I am attempting to set the

    underline
    > > > property? Thanks in advance!
    > > > --
    > > > Sherwood




+ 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