|
楼主 |
发表于 2009-1-14 15:38
|
显示全部楼层
Function ForeFontStr(m As Range, u As Integer) As String F3 J& d, ]0 p6 }) s* S
a1 = "\F" + m.Characters(u, 1).Font.Name + ";" ‘字体
+ {( s1 |" w) D+ x, _ g7 Xa2 = IIf(m.Characters(u, 1).Font.Superscript =
% J9 W6 ]& {! K# jTrue, "\H0.33x;\A2;", "") '上脚标( f9 ~2 v# E5 ~5 H( U1 j8 ~
a3 = IIf(m.Characters(u, 1).Font.Subscript =
( x2 f& }4 |+ o: |" ~; ?True, "\H0.33x;\A0;", "") '下脚标' A. ?4 R" J. @$ S ]# e
a4 = IIf(m.Characters(u, 1).Font.FontStyle =
+ _$ d9 Z9 R" g, u"倾斜", "\Q18;", "") '倾斜& O9 |' W0 e3 o- d5 H/ h' P, a1 ~
a5 = IIf(m.Characters(u, 1).Font.FontStyle =" l$ v* e& @, t6 I; o
"加粗", "\W1.2;", "") '加粗' }# f$ ?; E5 P$ S0 H
a6 = IIf(m.Characters(u, 1).Font.FontStyle = 7 I( S' B0 E$ Y, O, f; c0 h' ]3 b; A& c
"加粗 倾斜", "\W1.2;\Q18;", "") ' 加粗倾斜 9 o# d A( a/ k0 I0 l
ForeFontStr = a1 + a2 + a3 + a4 + a5 + a6
2 b: k0 M& {( q/ |End Function
5 `4 Z: N( T+ q N! U- w0 h' g8 I3 @9 Q6 W7 }+ M
---- (2).表格中表格文字位置的转换
- _& B) m' |0 y7 l---- 对文字对象的属性的直接控制来实现,通过with….end with 结构可以很容易地控制文字的高度、图层、颜色、书写方向。由于Mtext文字提供支持的排列位置分为9种,必须根据Microsoft Excel表格文字的排列方式加以合适的判定,然后进行转换。其具体的实现方法详见下面的程序。
- Y5 o, c2 W$ `( v7 |0 ]Sub kz( )) h0 M9 g+ j4 B$ X2 _, t- x
With textObj ‘文字对象
: `, o2 q( L* K+ x4 U! P.Height = textHgt5 ?7 G- s4 f' M# W/ d v) D; @) v
.Layer = newlayer.Name ‘设置图层) D0 i8 K; o2 T- _' H5 z
.Color = acRed ‘设置颜色
7 a# h% h4 B2 Q Y8 b.DrawingDirection = 1 ‘设置书写方向
: H( I' y0 N) R. e1 K, C4 q, kIf (ma.VerticalAlignment = xlTop _* i7 j0 `. E& _+ r, n
Or ma.VerticalAlignment = xlGeneral) _* b. Q9 K c2 @% M
And (ma.HorizontalAlignment = xlLeft _$ A3 [' T+ o8 ]6 n8 C4 V% ^; ~
Or ma.HorizontalAlignment = xlGeneral) _
" T& ^1 E. ~; n+ f6 P' bThen .AttachmentPoint = 1 'acAttachmentPointTopLeft
1 v* ^8 l( }+ j$ M: DIf (ma.VerticalAlignment = xlTop _8 N7 _8 i6 S, y: ^* r
Or ma.VerticalAlignment = xlGeneral) _' X& b& _) u& ?" }
And (ma.HorizontalAlignment = xlCenter _3 X! V+ X4 c) S/ ?9 R6 n. [
Or ma.HorizontalAlignment = xlJustify _
6 c9 V) N7 u" |( Y. Z: h! WOr ma.HorizontalAlignment = xlDistributed) _3 A' _9 H: `' g: D4 I( f0 B
Then .AttachmentPoint = 2 'acAttachmentPointTopCenter
6 B6 o& }* q. ^( HIf (ma.VerticalAlignment = xlTop _
& m: e# R" p( C) S: C" _5 t2 k0 nOr ma.VerticalAlignment = xlGeneral) _8 V3 I; R& y8 @) {9 `
And ma.HorizontalAlignment = xlRight _
) H5 c: S9 K, d% Q; OThen .AttachmentPoint = 3 'acAttachmentPointTopRight
( ~+ U5 w/ V8 ?4 T, l" W. hIf (ma.VerticalAlignment = xlCenter _
; Y F4 P7 g+ W! MOr ma.VerticalAlignment = xlJustify _
) M1 T5 Q1 T4 D% X: ^3 |Or ma.VerticalAlignment = xlDistributed) _
* d/ _; E# w, W/ |- ?( ?: qAnd (ma.HorizontalAlignment = xlLeft _
% z, r: F. J |' ?' | w- G% COr ma.HorizontalAlignment = xlGeneral) _% _( l4 m3 Q0 h' f) O4 L1 ?
Then .AttachmentPoint = 4 'acAttachmentPointMiddleLeft, i; a2 w" S# S
If (ma.VerticalAlignment = xlCenter _
1 u4 f8 j. a" g3 A, q' OOr ma.VerticalAlignment = xlJustify _
, [* ]1 r$ A' L7 j t: n9 C" b) `Or ma.VerticalAlignment = xlDistributed) _
( Y& _' {- Q# a' t& R; nAnd (ma.HorizontalAlignment = xlCenter _
9 u( C/ Z8 o& p9 Z$ _0 W' qOr ma.HorizontalAlignment = xlJustify _$ |# D2 i' o0 @' p
Or ma.HorizontalAlignment = xlDistributed) _
0 e4 z; A- y4 n1 N4 R: B- c6 pThen .AttachmentPoint = 5 'acAttachmentPointMiddleCenter6 C& ^$ S+ }) ^) G/ x
If (ma.VerticalAlignment = xlCenter _
7 T% j' ~+ l9 t dOr ma.VerticalAlignment = xlJustify _" @, B) r& g+ M' n! s- D0 ?7 C
Or ma.VerticalAlignment = xlDistributed) _1 z: i+ E+ v7 v/ Y1 Z
And ma.HorizontalAlignment = xlRight _# g5 w* a8 R F7 t
Then .AttachmentPoin |
|