02-24-2009, 08:41 PM
Macro
;/exe 1
out
str sn="0000000000"
ARRAY(str) a
ExcelSheet es.Init
es.GetCells(a "sel") ;;gets selected cells
;this code gets 1-based row and column index of top-left cell of selection
Excel.Range sr=es.ws.Application.Selection
int sx(sr.Column) sy(sr.Row)
int r c
for r 0 a.len
,if(mes("Row %i" "" "OC" r+1) != 'O') break
,for c 0 a.len(1)
,,str& s=a[c r]
,,int x=3-s.len
,,if(x<=0) continue
,,s.fromn(sn x s s.len)
,,out s
,,es.SetCell(s c+sx r+sy)