Consulting

Results 1 to 6 of 6

Thread: Add lines in excel comments through VBA

  1. #1
    VBAX Tutor mohanvijay's Avatar
    Joined
    Aug 2010
    Location
    MADURAI
    Posts
    268
    Location

    Add lines in excel comments through VBA

    Hai,

    I am trying to add comments into cells line by line like below

    Sl No Name age
    --------------------------
    1 vijay 25
    --------------------------
    2 kannan 30


    i set space for "SL no" to "name" 30 and "name" to "age" same 30
    and i write code to make each line the code does if lenth of name < 30 then add spaces upto lenth 30 also for age and using vblf const for next line the string variable gets as above and last i set that variable to addcomment method

    that works properly but the problem is the size of letters and spaces not same my code result like this

    Sl No Name age
    --------------------------
    1 vijay 25
    --------------------------
    2 kannan 30
    --------------------------
    3 muruganmur
    --------------------------
    4
    28


    how to i correct this or make same size for each letters and spaces

    please help

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    You need to use a mono-spaced font, not a kerned font.

  3. #3
    VBAX Tutor mohanvijay's Avatar
    Joined
    Aug 2010
    Location
    MADURAI
    Posts
    268
    Location
    how to use mono spaced font? or any functions for convert kerned font into mono -spaced font

    i don't know anything about kerned or mono-spaced fonts

    please help

  4. #4
    VBAX Tutor mohanvijay's Avatar
    Joined
    Aug 2010
    Location
    MADURAI
    Posts
    268
    Location
    thanks for reply kennth i google about monospaced fonts and knew

    how to i set font type to comments

    i try below code

     
    dim a as comment
     
    set a=range("a1").comment
     
    a.shape.texteffect,font="Courier"

    but the eroor occuers "only for wordart objects"

    how to i solve it

  5. #5
    VBAX Tutor mohanvijay's Avatar
    Joined
    Aug 2010
    Location
    MADURAI
    Posts
    268
    Location

    Solved - Add lines in excel comments through VBA

    found code for set font to comment

     
    dim a as comment
     
    set a =range("a1").comment
     
    a.Shape.TextFrame.Characters.Font.Name = "Courier"

    thanks kennth

  6. #6
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Courier is the most common. Letter Gothic is another that can be used.

Posting Permissions

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