PDA

View Full Version : Add lines in excel comments through VBA



mohanvijay
03-18-2011, 08:44 PM
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

Kenneth Hobs
03-18-2011, 09:05 PM
You need to use a mono-spaced font, not a kerned font.

mohanvijay
03-18-2011, 09:26 PM
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

mohanvijay
03-18-2011, 09:51 PM
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

mohanvijay
03-18-2011, 10:10 PM
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

Kenneth Hobs
03-18-2011, 10:54 PM
Courier is the most common. Letter Gothic is another that can be used.