|
楼主 |
发表于 2009-1-14 15:38
|
显示全部楼层
Function ForeFontStr(m As Range, u As Integer) As String
& N, |( f" ^8 z- fa1 = "\F" + m.Characters(u, 1).Font.Name + ";" ‘字体1 E3 {$ D2 z7 Q" d6 o% }7 W
a2 = IIf(m.Characters(u, 1).Font.Superscript =
2 x3 ^5 ]0 u- k5 eTrue, "\H0.33x;\A2;", "") '上脚标
7 \' O8 k0 g: }8 M: T8 oa3 = IIf(m.Characters(u, 1).Font.Subscript = ( J) M- p$ C. x) ]$ \1 P' L
True, "\H0.33x;\A0;", "") '下脚标& P: K6 F" A( z: f! S
a4 = IIf(m.Characters(u, 1).Font.FontStyle =
, P* q& J& J0 o, s8 b3 P6 {! s& e& X"倾斜", "\Q18;", "") '倾斜
1 n( G! R8 M9 ^; H. }1 ja5 = IIf(m.Characters(u, 1).Font.FontStyle =0 m I9 S' c7 L* x% \+ t
"加粗", "\W1.2;", "") '加粗: L( V- V/ J/ L/ J
a6 = IIf(m.Characters(u, 1).Font.FontStyle =
- _ B$ \$ {' n% x4 A& g"加粗 倾斜", "\W1.2;\Q18;", "") ' 加粗倾斜
3 g* U! X/ N/ ZForeFontStr = a1 + a2 + a3 + a4 + a5 + a6 @* `$ r6 ?& f5 K* w
End Function 1 [ m% o6 t0 I4 [ D, |% p- O
5 ^0 M9 ^ S( ?+ e---- (2).表格中表格文字位置的转换 3 M+ \! E) I3 w, ^2 p5 b
---- 对文字对象的属性的直接控制来实现,通过with….end with 结构可以很容易地控制文字的高度、图层、颜色、书写方向。由于Mtext文字提供支持的排列位置分为9种,必须根据Microsoft Excel表格文字的排列方式加以合适的判定,然后进行转换。其具体的实现方法详见下面的程序。
0 T6 p) j; ~' d8 _# wSub kz( )7 H+ W L- [8 s# h% ]7 D) F3 o
With textObj ‘文字对象
' S. R5 B& I" o* i.Height = textHgt
2 j) T# C* D- T* q6 r* l.Layer = newlayer.Name ‘设置图层
- x, j: s$ y% g/ v4 x# V4 \5 j3 H3 W/ C.Color = acRed ‘设置颜色; M" l; }4 \. \8 m
.DrawingDirection = 1 ‘设置书写方向
8 g9 f$ s, c' ~ @8 w+ HIf (ma.VerticalAlignment = xlTop _* U0 P- G8 ]6 \- q
Or ma.VerticalAlignment = xlGeneral) _0 G9 s. [; u& u5 C( Y2 a# X; m; h
And (ma.HorizontalAlignment = xlLeft _
" g* V6 {! h& Q/ y2 }% o- XOr ma.HorizontalAlignment = xlGeneral) _
! E& i4 y2 |3 D8 y, L# h7 `" C _Then .AttachmentPoint = 1 'acAttachmentPointTopLeft# U( t: A; {9 \% b
If (ma.VerticalAlignment = xlTop _
! R1 V/ O; }( w# G, c: ~7 WOr ma.VerticalAlignment = xlGeneral) _
9 s5 Y" t& ]/ O0 W! l* PAnd (ma.HorizontalAlignment = xlCenter _) e5 W7 v* ~! H% N! E
Or ma.HorizontalAlignment = xlJustify _) q6 q- {4 ?( I0 Y, M
Or ma.HorizontalAlignment = xlDistributed) _' f" }0 j4 w1 X* l4 S7 B
Then .AttachmentPoint = 2 'acAttachmentPointTopCenter
, E3 u( u9 J4 F. nIf (ma.VerticalAlignment = xlTop _
+ b/ T3 ]! c' [9 T0 zOr ma.VerticalAlignment = xlGeneral) _5 J, T9 |% C% m& A
And ma.HorizontalAlignment = xlRight _+ K' z% v# p- c8 ~( }8 i
Then .AttachmentPoint = 3 'acAttachmentPointTopRight
# u; Y8 | i) ?, L6 y. }4 N# DIf (ma.VerticalAlignment = xlCenter _
, E" {) r3 N3 ]7 u" ^Or ma.VerticalAlignment = xlJustify _3 k- z$ b9 D3 j& v! b- W0 f
Or ma.VerticalAlignment = xlDistributed) _5 o/ E( u% n7 Y" Q0 F0 @! a
And (ma.HorizontalAlignment = xlLeft _
; Z% ?: e( W9 h: N( ?, [Or ma.HorizontalAlignment = xlGeneral) _
: M, F4 }1 e3 y0 w# L) FThen .AttachmentPoint = 4 'acAttachmentPointMiddleLeft
$ l7 r8 W0 C5 \6 N& aIf (ma.VerticalAlignment = xlCenter _8 a' |) `# G3 Y* _
Or ma.VerticalAlignment = xlJustify _0 h4 |* p2 U4 J7 E- [% Q) I
Or ma.VerticalAlignment = xlDistributed) _
- y% g5 Z Z! i/ P0 F$ O7 TAnd (ma.HorizontalAlignment = xlCenter _
$ z" Q) T8 u" R% ]5 NOr ma.HorizontalAlignment = xlJustify _2 D' G9 ], ]' b! i' i- M
Or ma.HorizontalAlignment = xlDistributed) _6 h0 l) o, T/ ^) n# T6 I6 ]2 d
Then .AttachmentPoint = 5 'acAttachmentPointMiddleCenter$ ]8 l- c8 Y' b: w
If (ma.VerticalAlignment = xlCenter _
" Y3 e# `2 }& B6 C* v/ WOr ma.VerticalAlignment = xlJustify _
, K; {; U/ k* O- D8 WOr ma.VerticalAlignment = xlDistributed) _
! Z5 t( h: l3 ]* j, a w* fAnd ma.HorizontalAlignment = xlRight _
( t% j9 q7 y- M: ]6 d* ?Then .AttachmentPoin |
|