Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Mar 2002
    Location
    Virginia
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Get Charater Parameters (Word 2003)

    How can I obtain the parameters (font, character number, Unicode-t/f) of a selected character in a document?

    I'd like to "get" this data for any "interesting" character I come upon in a document, so that I can then write an "InsertSymbol" vba statement for the character. It's especially useful for special bullets, etc.

    myFont = Selection.Characters(1).Font

    doesn't work. I don't even get anything sensible off of the list of properties/methods for the other two parameters.

    Thanks,

    Fred Holmes

  2. #2
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Get Charater Parameters (Word 2003)

    To identify font characteristics, you'll need to use name, size etc. For example:

    MsgBox Selection.Characters(1).Font.Name

    Others available are:
    object.Bold [= Boolean]
    object.Italic [= Boolean]
    object.Size [= Currency]
    object.StrikeThrough [= Boolean]
    object.Underline [= Boolean]
    object.Weight [= Integer]

    For ascii character code, you can use: asc(Selection.Characters(1)) to return an integer in the range 0-255.

    Alan

  3. #3
    New Lounger
    Join Date
    Mar 2002
    Location
    Virginia
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Get Charater Parameters (Word 2003)

    But I need the Unicode value. Is there a function similar to asc() that returns the Unicode value?

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Get Charater Parameters (Word 2003)

    The unicode version of Asc() is, if I recall correctly, AscW() -- the W means "wide."

    Note: if you are poking at symbols, strange rules apply. Lots of past threads on that.

  5. #5
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Get Charater Parameters (Word 2003)

    Take a look at this MVPs article, and specifically the GetCharNoAndFont() macro about a third of the way through the article.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •