网上搜索到如下方法,暂未验证,谨慎使用
8 u. X- Y% F- L6 q1 b# ^1、VBA编程法--- Sanjay Ramaswamy
' Y# B! m( P' I3 Y' Y' @' f- Z e6 q( K: T/ R' u
# t! x5 d8 [+ T& q8 N+ Q
- {/ g3 R7 j6 J. {% }用法就是新建一个空的Excel表格, 然后再VBA 编辑器里面复制下面的代码,然后add a reference to “Microsoft Excel 12.0 Object Library”。 运行即可。
' a- ]5 T6 M: }' Z
; ?5 L* _6 L, N6 I' \5 u 2 V. b& P3 A& G' U0 N
! o) H* r, D9 Y7 m- ? J% v8 d
Public Sub ExportParameters()
4 l% p% x. x8 F' v& N9 c+ ~1 Q* V1 v
* M- l0 ~. L7 o* x) }( ~3 b" C8 J
8 w8 q: R+ s+ G; w Err.Clear
; N* E1 a3 Y1 n" h0 m( G0 v. r: D: ?& d1 ^7 p3 K3 t& H
Dim oExcel As Excel.Application3 |& J" y% T, Z; L7 Z+ L/ X; G9 F
" G; \5 i# d2 n3 J% o$ t Set oExcel = GetObject(, "Excel.Application")' T( [6 k% D; _& T6 c& B
8 Y5 l, t, L6 @& a7 `3 _, K If Err <> 0 Then
) w# n' X6 z/ u
/ Q% K# B( I3 T, d MsgBox "Excel must be running"
5 |% |) B. Z& G; l, @9 j- ]( }
" u4 E q! t' }, E) s Exit Sub
; q5 u' |# @. D1 }3 h8 `: p9 T9 {+ P/ }& W5 t2 y Z( r
End If. {* U* }7 p8 v! j4 S" E
" m/ d+ o5 f- e1 R
# e' f6 `% O& t% c& U
2 _0 J% B7 }+ v
Err.Clear
7 |; o7 J6 d' [% a1 D0 Z# p3 Q/ E
, T, x+ y# l/ F+ R4 ^" r5 ^ Dim oSheet As Excel.WorkSheet/ p4 I! ^- g0 j
2 G8 D# A" H4 [/ H9 R Set oSheet = oExcel.ActiveSheet
# Y* N' I! H) [/ I1 J! E$ Y
7 U* P& y9 u* ]5 z; X. O: x If Err <> 0 Then7 R$ g) k. L k$ u$ t. a
% P+ B9 O5 X! z. x' h" ]
MsgBox "An empty must be active in Excel"$ ^6 w" R3 v! T, f1 l$ ?) i
3 p& j8 G0 v t9 U
Exit Sub
0 H, z: H. P' f+ y8 d! z
9 n/ v1 j% y4 J/ {- C% d5 N End If# F& w) s; \; \% G/ y% u
' M, _, v- R/ l8 ]% F
3 H3 R1 g# v+ V) R
8 d- Z7 T3 J3 R% h6 A7 \ Dim oDoc As Document
. X$ \3 N E* ~( `$ Q* V2 X' u' K' d4 I' [: f8 H9 d6 {
Set oDoc = ThisApplication.ActiveDocument3 i3 b9 \3 g( v. o" N+ L& ~
, w% s3 `. P/ l) ^4 P9 u/ r
% |8 C1 z) k' F
; g- x4 P9 s7 ~! c( m9 b oSheet.Cells(1, 1).Value = "Name"& j0 k5 L8 d! a2 w9 p+ |9 a
; E. ~! B7 e% P/ O
oSheet.Cells(1, 2).Value = "Units"
1 @3 j* x. w" L% y1 \2 y: a' Q, p1 F) l6 T- l# d9 I
oSheet.Cells(1, 3).Value = "Equation"
* r3 m8 n# U3 y' Y' \4 D/ _$ u# D! B, a7 r* Q
oSheet.Cells(1, 4).Value = "Value (cm)": o9 [5 H6 e5 t y. P( T) [$ ]
4 q. J) c9 `6 ? s
4 s H6 |' \0 n4 b. D- ]" z/ K# l6 M S9 M- B7 z# w k1 _
oSheet.Cells(1, 1).HorizontalAlignment = Excel.xlCenter! g8 m3 B& m( U& }) R6 Y. u# Z
* S5 l) `7 |* s& k$ v X$ Y/ s
oSheet.Cells(1, 2).HorizontalAlignment = Excel.xlCenter& F5 X& f- Z$ H3 H" x* f
: z/ R" L4 A# t' z, w5 s; Q9 y0 v1 i% U oSheet.Cells(1, 3).HorizontalAlignment = Excel.xlCenter6 G3 A* c1 C8 a F t' C
2 `$ K3 q& I7 S! T) t# v
oSheet.Cells(1, 4).HorizontalAlignment = Excel.xlCenter
0 X p9 ] G5 g: v
5 k0 o$ x. W# Q) i. z oSheet.Cells(1, 1).Font.Bold = True
F7 K% H5 y# Z6 L( K) Z- m) `9 Z9 N6 R# ~ s' f$ q- X0 F4 `0 @" E' _
oSheet.Cells(1, 2).Font.Bold = True# |+ s3 ~( k' Q7 @# b
% }% m! c: ~# P) l' O
oSheet.Cells(1, 3).Font.Bold = True
) X$ C3 n3 M' _" ^& N
& H( f; M8 g" i7 S5 M' q oSheet.Cells(1, 4).Font.Bold = True
0 B5 q0 E: U" W6 N5 [3 i3 H7 X2 Z1 i4 B2 y2 o' y" e- R2 E$ U
. [) `1 r; Z6 N, A. s" D' N/ F6 W7 T& t6 t4 e4 U
oSheet.Cells(3, 1).Value = "Model Parameters"
5 [$ \6 ]% d: {: ]7 {" i. ?5 m0 o' |7 K
oSheet.Cells(3, 1).Font.Bold = True$ Q& i2 w' Q: R; ]
! N2 G$ U- i2 L$ Z2 x+ X# D2 r - s! N/ h) g* d9 H( d/ u$ k1 t
L: M: Y4 W9 b8 @6 A) V# e
Dim i As Long: U* h/ l2 D. F& {/ B2 s
i: H/ [+ n, Y% [. D i = 4
I! p: m0 G& M4 B% ~# t5 t
. L4 `$ B I* T+ g& b Dim oModelParam As ModelParameter
5 q4 G. m" z& P* L$ J
/ K. D! H. J; t# } F- a2 E$ [' n For Each oModelParam In oDoc.ComponentDefinition.Parameters.ModelParameters
4 _ A: ~: U d; ?/ i( C( K. w
0 g1 o: k L3 C; W / l+ @4 G( R; N9 O4 l
6 h7 v( }* B8 e+ J9 y$ t
oSheet.Cells(i, 1).Value = oModelParam.Name4 G/ ]# E& n) l: f/ a' Q
, \! T4 s% l7 M b R9 ~- F7 V
oSheet.Cells(i, 2).Value = oModelParam.Units
( ?/ G! l$ K, U; @* r: A$ G7 [
$ q# e: z% H* q; l! e( f; s" V oSheet.Cells(i, 3).Value = oModelParam.Expression
9 A3 L8 x' O, W' |( W' }8 C
0 U; U8 G q/ H5 f oSheet.Cells(i, 4).Value = oModelParam.Value
) v" V3 b' t8 X, L [5 I7 @' l4 a# d3 {' J, q; h2 i) u3 n
5 Z# I9 P$ j% y- ?6 X% T) t2 m0 `; B3 e) n
i = i + 1
6 |9 w$ z( l3 l q8 |
8 f- Q0 C) A: U/ o Next
+ j' I$ k/ B6 x; t+ r( O, F4 V7 A* f' A
7 Q5 J' s% l7 D% n( `. u
8 B B" ?+ e3 u1 i i = i + 1$ I: @0 J% ?. H" \" y- s% T
! b7 \/ h# E: f/ J2 f' F1 X
oSheet.Cells(i, 1).Value = "Reference Parameters"# U7 g v; C! x3 o
8 W0 k& t' i6 x1 X0 p2 H
oSheet.Cells(i, 1).Font.Bold = True7 h( }# h; H3 j
u2 w0 u" w" K" J6 T6 V& M3 X
i = i + 1
, ?2 ?; e6 S7 Z
+ b5 w9 @% V# ?9 K" P ( Z, f5 Y8 M, F2 A- ~/ ~8 ?' l+ u
) h! z+ W8 \- e Dim oRefParam As ReferenceParameter
4 b' Z+ M6 ?! E! m# }% S
+ Y+ ^4 N( l u- @4 {) ]+ Z" X* E For Each oRefParam In oDoc.ComponentDefinition.Parameters.ReferenceParameters1 e9 B4 c5 a8 S3 S3 r
5 q! X* K: w0 W W9 Y* j+ c + s. y& L* k7 h7 E" W' v( Q% T
1 q3 S5 g9 _- f9 {1 S, e5 P8 m- C' S oSheet.Cells(i, 1).Value = oRefParam.Name
, m5 w: w3 K2 o. E6 r9 _& u+ {. u
, y/ @) P# W, h5 Z& G9 `) R oSheet.Cells(i, 2).Value = oRefParam.Units
5 h. M& T O- V e- L/ e7 [1 F2 c/ a7 \% D7 j) Z/ e- B6 k+ b
oSheet.Cells(i, 3).Value = oRefParam.Expression1 B0 e3 _" z5 V$ o$ H5 j5 C/ V
! F" b3 o( z8 ?- g1 g8 V
oSheet.Cells(i, 4).Value = oRefParam.Value
& j+ q1 t6 n9 l r$ `& U0 x w/ }, t8 A/ M
/ e) m# H. a: u/ Q; i( D( g x, r" F" W+ j4 w) d, N* x K. E
i = i + 1
4 Q/ b" ?$ {8 W
4 m6 c1 |' C3 Z: w, V Next7 U0 q# d+ C. x; E9 F$ e8 b/ Y/ _7 n
% L, \; v$ b1 x/ n8 ~1 y' T
2 i% A7 `0 H/ p/ k1 T) A
* T/ l2 l+ I) n0 Y: s
i = i + 1
; V, O. ^- ?9 N- i3 _ b8 ?2 M
! i6 E8 g( J h oSheet.Cells(i, 1).Value = "User Parameters"
7 @. I' [! p) }# N
6 |, ^# H* g/ S! |( w) P1 ^! f oSheet.Cells(i, 1).Font.Bold = True
- ~6 H, b5 g- ~0 n/ Q0 k0 m5 `+ t& k, C
i = i + 1; f& L8 u! ~' z! ?/ Y. b( F1 \
: g8 d8 W- ?- ^, j5 Y" v ` a k7 z; ?0 a/ K) w9 q
q( l$ I3 l/ D6 J- j1 Q1 w Dim oUserParam As UserParameter
/ E0 U) m! m- U" T, t# @! q/ g" ` f0 c% X
For Each oUserParam In oDoc.ComponentDefinition.Parameters.UserParameters
, w/ Q7 f1 K) E0 m. r2 h1 U. a
# D: a! J/ v3 D0 P" s- e$ B 4 o% i" @7 C; d/ C6 ]6 G( H# W
( m9 p1 U: o1 Z9 r3 n. t4 U
oSheet.Cells(i, 1).Value = oUserParam.Name
5 K, p P( i- ]
0 y. I, o; e- r oSheet.Cells(i, 2).Value = oUserParam.Units# z% j5 g1 K _& W0 K' ]8 }' X
1 r3 u) I" q& W5 s
oSheet.Cells(i, 3).Value = oUserParam.Expression
1 r4 X! u7 f* \
8 E6 b% b b+ e: X. U. @ oSheet.Cells(i, 4).Value = oUserParam.Value
, G( o: k' I2 ~! F1 U0 s/ E. U, {8 e W4 Z3 t& _
$ p6 n& X: r0 Y+ N& `( T; u" d; ~4 D+ S* T8 O; H. @
i = i + 1
( H) E9 b) O* t0 ^, H, F# u7 O: _+ V2 k, t8 S! f
Next, x0 @0 i% B% v3 L9 h5 p: B( f' p6 ?
% W7 R1 |7 K+ d Y" |8 a
4 ~8 N6 l3 \( J- N: ~" Q% L2 _5 c4 W/ s% \' U
Dim oParamTable As ParameterTable& o9 `, T5 R( l- r
u% N$ ~1 q, s! f For Each oParamTable In oDoc.ComponentDefinition.Parameters.ParameterTables
1 t q7 D/ x. K* d& f1 N5 o
' Y: R7 f! r- ^% b7 F 0 ]( @8 a: U$ c2 }" q! D' ]
5 u0 Y( j8 Y5 a5 j! ~' d0 y
i = i + 17 ~- f7 d# o1 d& n, x8 b0 p- Q
& f8 `& R: Q, d- S8 u oSheet.Cells(i, 1).Value = "Table Parameters - " & oParamTable.FileName
8 c9 W/ k- h& W4 V R9 o0 [1 v4 d5 s: B3 V( I
oSheet.Cells(i, 1).Font.Bold = True
. ?# e, k) Z- }2 I
6 f0 \6 f! Z/ E/ J( a i = i + 15 Y+ Z9 v+ v+ G# K) z+ f% \2 t6 q
8 }& O9 z& b5 ]" B
9 f" f. _2 \! D8 P7 K$ _* C) `6 g7 K% {$ t+ T3 a7 P) o4 a
Dim oTableParam As TableParameter
6 U2 j/ c: L5 l. T9 H% o9 _8 p1 I: J: _, u& \
For Each oTableParam In oParamTable.TableParameters3 }+ O4 F, T9 Q6 O6 L: Y7 z" W
9 j( t2 ^& m3 C 8 F: S3 [1 E* I- H" w- D5 U5 H/ ~- a+ J |& \
6 _* {7 C0 a. d! c/ I0 o
oSheet.Cells(i, 1).Value = oTableParam.Name. e! p+ J0 l8 j! D( E: t
7 _! k1 r; A) M6 n6 k oSheet.Cells(i, 2).Value = oTableParam.Units# Z# d# H1 m, Z4 ?2 s( t# A
( B$ o X; Z1 V+ Q oSheet.Cells(i, 3).Value = oTableParam.Expression, w* n+ m* P( w
- @5 E: I+ Z) Y! R3 M6 Z6 X
oSheet.Cells(i, 4).Value = oTableParam.Value2 X( o( P8 O$ Y% C" Y. B4 }
& S# A* S+ G. R6 B' q& I ( @# _6 m. Y k/ G
4 K" Y& S9 y9 J; x/ w
i = i + 1
9 }' Z2 ]; y+ C9 Q" Y
+ F: V: w( K m6 b+ m5 V5 f Next7 m$ O% M+ j" @! ~
, m8 y% t! l, l# Z4 Z* O
Next0 k6 G' e1 g- ]. V& D
& R9 |1 |" V f6 Z; s6 T * j# G9 A: P5 i
( D. D/ w0 g! u! K
Dim oDerivedParamTable As DerivedParameterTable
C2 p$ ]2 `4 {1 ?7 m
7 t* \# x5 R$ p$ {: i6 _0 Q4 ] For Each oDerivedParamTable In oDoc.ComponentDefinition.Parameters.DerivedParameterTables- g% a) q% N3 K
& A( _1 u- |8 C, r. F* ?8 E1 ~9 c; v
" q6 G( L3 z7 U3 L, ]0 F
+ U# r0 i l& b6 i& y/ w5 v1 O- j i = i + 1) j# M# U2 @9 W- c0 w, V% A+ J
4 g$ @) @1 u9 z: g
oSheet.Cells(i, 1).Value = "Derived Parameters - " & oDerivedParamTable.ReferencedDocumentDescriptor.FullDocumentName
# u! b( n7 k7 d0 L5 N5 l0 w, Z% Q) R& Y0 {, D+ b0 }1 V
oSheet.Cells(i, 1).Font.Bold = True$ ~) b7 a2 X; E" ~0 `, G
, _0 V6 d& j5 m8 i1 a, m2 [
i = i + 1
9 B) i$ } n" P$ E Y' Q2 V7 h! q- b! X" E7 A' k
3 q9 S4 ~. g8 F) Z" L$ ]7 G% ^
. `6 b, d" h3 X& h& k0 |: v Dim oDerivedParam As DerivedParameter
" w0 G* e6 I$ k) b
% I! \ \0 g2 J9 J For Each oDerivedParam In oDerivedParamTable.DerivedParameters% y# Y* ]1 E( F: y! i) N6 }( m! A
6 ^6 |7 u& X ]1 E, D ' B. L8 ?- d7 O! y
; Z0 g$ r- O& v
oSheet.Cells(i, 1).Value = oDerivedParam.Name" j% F. E4 `, C* D: S* a
: }$ O/ `$ O' f oSheet.Cells(i, 2).Value = oDerivedParam.Units
. P9 o, ~; A+ X7 i/ ?% R3 t) X2 E! T% M
oSheet.Cells(i, 3).Value = oDerivedParam.Expression
/ f* `$ C- v* o u4 V2 F
4 s0 j* @1 |% I' l' c oSheet.Cells(i, 4).Value = oDerivedParam.Value
6 z6 H: v. _/ O9 r3 p' n
+ d& ]3 N8 Z, R' R. r$ y' Q
7 }) L6 [2 t% m: E; q. ?# y3 F6 N! w) l" ^
i = i + 1
2 Z8 R1 c* ?$ F" S+ e3 [7 h. ]# m: }) G7 k( h0 H n
Next: b0 @1 V9 w! s' f9 l- o
* n2 p$ H7 c2 b4 V7 E: o5 d& j2 g Next8 M6 G" O* D1 A
6 u/ T' R- ?! A0 W, V. u$ H
End Sub
) }( d" M ~8 n! i5 n1 L( _3 K4 a% V: C" ?
1 S9 W1 J6 ?, H; X
- |$ I8 p) ^$ F& j
5 B/ B3 K' f4 J; `$ b( [4 o3 P
. k3 f% N7 y) u c, z第二个方法--- iLogic方法 , 感谢xiaodong Liang7 b4 p9 h4 H4 x& _
6 ]" O6 c' f% M4 z; s
- E6 I' C+ s. C% [+ D+ \) A3 S
, [: r$ m0 V5 i: ~5 q" I/ [用法,新建一个test.xlsx在C盘下面,然后复制下面内容到一个规则里面。运行即可。" _+ ~; H4 t4 }- X. B& V) F
4 V* k. S% B6 b' I! ~/ L, Q' H
/ @& [* \, ]# `: }0 g5 m- }( }
: {5 t, A- `, s # p) J: V- ^, \% T4 P
% B& z- H! e9 X A& Y, z4 r 'Open Excel
0 O/ B. W9 n7 n4 O! {( ~ GoExcel.Open("c:test.xlsx", "Sheet1")5 m0 k7 i, |4 O8 E+ u% c+ t; C9 l/ i
4 |1 [; B/ Q* H& @ ?: @! G 'Title of column3 a- {' q1 W( d1 b3 b' W. y
GoExcel.CellValue("c:test.xlsx", "Sheet1", "A1") = "Name"
0 i) {/ _" L* K, X7 K+ |, I GoExcel.CellValue("c:test.xlsx", "Sheet1", "B1") = "Units"
4 ~6 [3 ?1 i }5 T/ ]& w4 T9 L& D GoExcel.CellValue("c:test.xlsx", "Sheet1", "C1") = "Equation"
0 P8 Q/ C8 e n( I- \ o GoExcel.CellValue("c:test.xlsx", "Sheet1", "D1") = "Value (cm)") F2 n4 V) y- E$ C3 V' @+ k4 k
2 s, E, X& v# o7 ^/ Y2 z4 `1 y$ x
'Model Parameters/ H& u4 h" M7 @" X0 N6 b
Dim oCurrentIndex As Long = 31 b# b: r; _' R. g2 Q7 G' O
GoExcel.CellValue("c:test.xlsx", "Sheet1", "A" & CStr(oCurrentIndex)) = "Model Parameters"
- l! P6 j0 Y& F+ d1 N2 w/ ^ ( |, N' Y/ D3 G9 p
Dim index As Long* w2 N, k2 C6 b* b
Dim oIndexStr As String
- o0 n6 Y W4 ]9 ]9 `
, C7 A4 j* W# ~' G/ U8 U% K Dim oModelPs
5 Q% l5 ?# b4 b m8 n1 k" D oModelPs = ThisApplication.Activedocument.ComponentDefinition.Parameters.ModelParameters0 m! Q5 |# J) X2 [
8 V$ O q" d- H: L, |. [, k; xFor index = 1 To oModelPs.Count0 P+ `* T; w/ C. \; c* k
1 e8 N9 t& d& A: ?
7 w+ w2 @, T: o6 q& Q+ L oIndexStr = "A" & CStr(oCurrentIndex + index)# ^$ B6 o$ `5 m
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oModelPs(index).Name
/ \5 |+ Y9 ?, |1 V6 R0 Z4 a
: K6 ^4 H% Y. r+ g oIndexStr = "B" & CStr(oCurrentIndex + index) , o# G4 B1 X0 r( f2 `$ E: i% ~
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oModelPs(index).Units+ h3 l9 |) T) g6 O
, T1 ^ A& U5 m' C, U9 ~
oIndexStr = "C" & CStr(oCurrentIndex + index)
& y- g) E9 R6 z; ^$ ]7 M GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oModelPs(index).Expression
; e" P4 q" k \0 m& | c9 b 0 w; L- Z! Z# ]3 f+ e3 u; `
oIndexStr = "D" & CStr(oCurrentIndex + index) , G4 H4 h. f* G. L: w
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oModelPs(index).Value8 R1 X8 Y) l9 l& l( P
Next5 r2 K' o+ G8 ?1 [1 n8 z3 x' S
4 b1 D- d) r' [( H% I
'Reference Parameters/ U/ j, o$ r4 N @ T
oCurrentIndex = oCurrentIndex + oModelPs.Count + 1) D, B9 Y( n7 s0 a5 |( F
GoExcel.CellValue("c:test.xlsx", "Sheet1", "A" & CStr(oCurrentIndex) ) = "Reference Parameters"* g x2 h/ R* g& j. H& B8 R
3 [# n+ \' z, i( }9 Y: O
Dim oRefPs
, H3 j, z) Q% ~2 l6 z* [5 P9 woRefPs = ThisApplication.Activedocument.ComponentDefinition.Parameters.ReferenceParameters& C' {, y3 w. \3 s
' A- j3 t. L; G9 i) I4 IFor index = 1 To oRefPs.Count# C# D7 N* Q# ?/ }
* I7 a* J1 P. w) F
oIndexStr = "A" & CStr(oCurrentIndex + index)
, F5 \1 B+ i5 c& m- ?& _ GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oRefPs(index).Name4 m3 [/ j1 r; }2 ^9 A
/ Z- C l% N+ l5 m: q7 J, K- ]' O oIndexStr = "B" & CStr(oCurrentIndex + index)
) O( L& H% Z D. I( {- S GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oRefPs(index).Units
( e2 L+ x& w- E* t6 b3 S3 V( k B
; J. V, M) L* V! Y* _ oIndexStr = "C" & CStr(oCurrentIndex + index)
6 A H: R( l5 B/ L9 G GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oRefPs(index).Expression
1 W3 I" b* \# G8 d! O
1 }1 R* J) D! ?4 u5 u* D, h y oIndexStr = "D" & CStr(oCurrentIndex + index)
5 z+ U* f) D/ x% p GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oRefPs(index).Value7 i2 I3 q Z8 {$ ~1 j5 m* X; n
Next( m0 J x$ X$ D$ _ G* H9 ?/ s
# ^8 G4 g9 m2 k" F4 O6 `" a8 s
'User Parameters
+ U" W2 T, {3 y2 K3 W- A/ n5 WoCurrentIndex = oCurrentIndex + oRefPs.Count + 1- [- \9 E! i% C' |% W# H+ ` [
GoExcel.CellValue("c:test.xlsx", "Sheet1", "A" & CStr(oCurrentIndex) ) = "User Parameters") g1 @& H& c X1 d9 k
/ m8 @, F8 p R0 p2 L C5 L) F
Dim oUserPs
1 l; `# F* H! ~' t+ v# ]( b2 u& E6 c poUserPs = ThisApplication.Activedocument.ComponentDefinition.Parameters.UserParameters& V! K* C9 A2 u+ W# ]
, J6 i" [ V0 P5 Y! W2 h$ w( |For index = 1 To oUserPs.Count/ ?" ^1 i; X5 ^4 H
2 {" d0 `4 {# l9 n: o! f oIndexStr = "A" & CStr(oCurrentIndex + index)* ]3 D% y ?$ D. `$ j3 `6 S
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oUserPs(index).Name
) b1 s0 M2 J" a" w+ ~
% h8 V) E3 c3 n7 g+ u3 b6 [ oIndexStr = "B" & CStr(oCurrentIndex + index)
1 V* U4 O( f) @0 p: v GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oUserPs(index).Units7 g3 S2 w8 f( T9 u* O/ ^
0 Q# A( {. ?* ~" H& F
oIndexStr = "C" & CStr(oCurrentIndex + index) ; j( c. b4 B( ]; \# p2 r
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oUserPs(index).Expression
8 _+ y9 u, `, Z 7 k- w, B. u$ S4 F: W+ E
oIndexStr = "D" & CStr(oCurrentIndex + index)
3 \6 q A: T2 O0 d5 q& M9 O, D0 y GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oUserPs(index).Value
7 b5 l8 W3 ]2 {( k. {7 X* nNext2 @4 l3 C2 C& |1 ]5 l
' |! h' U/ }2 |) H5 Z) }. O- l
% e* ]) I3 V2 k' L* d* U'ParameterTables. @' L) x: N4 E
oCurrentIndex = oCurrentIndex +oUserPs.Count + 1
4 N+ [; B k" ^6 vGoExcel.CellValue("c:test.xlsx", "Sheet1", "A" & CStr(oCurrentIndex) ) = "Parameter Table"
0 j3 i! R, G' G: s U' w
" Q# Z) T6 I a& ~Dim oPTables
- \8 f; I; \/ |oPTables = ThisApplication.Activedocument.ComponentDefinition.Parameters.ParameterTables; V/ a4 I9 ?& ~( H* K
4 @: y1 ?: }1 X8 X$ H' DFor i = 1 To oPTables.Count
C! h6 Q4 S* T. Q # L2 `/ f6 W: P% @; z. S
Dim oEachPTable# \& ?& Z; [0 N$ R. j
oEachPTable = oPTables(i)* `' b8 Y5 S% h+ U' G& a/ ~5 O
+ i3 C# a: k6 G. X
Dim oPTableParas
. e# ^; {+ u3 `/ V oPTableParas = oEachPTable.TableParameters 3 T# V# v# y( h' j4 t
( N1 {% d; @% x9 q, g" d v( B oCurrentIndex = oCurrentIndex + 1
2 O) W- s' H( F+ S+ s1 A GoExcel.CellValue("c:test.xlsx", "Sheet1", "A" & CStr(oCurrentIndex) ) = "Table Parameters - " & oEachPTable.FileName
# z" O4 c* q- r* ~5 a: ^ ( ]; c- [8 a9 d5 ]
For index = 1 To oPTableParas.Count
; S& n* n% j" K: J5 W n: a * P* M, J2 u# u9 `+ C7 e
Dim oEachP8 u' F& b: H1 p
oEachP = oPTableParas(index): k' _ N8 d. d* b7 L- K$ j
2 V1 n7 }& {$ Q7 ^( x: [- y5 z; l oIndexStr = "A" & CStr(index + oCurrentIndex)
) d# z4 N' m, |6 Z: U* W GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachP.Name
# F" v. a2 ~3 W, v
' v# h/ g5 n8 A oIndexStr = "B" & CStr(index +oCurrentIndex) # R: h, _" ]0 C7 f; o, J# @& ?: a
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachP.Units x" P V" M, u4 k5 O* L9 r& q
1 Y ^. C& W4 A$ ]9 P
oIndexStr = "C" & CStr(index +oCurrentIndex)
6 ]* ?( J* u/ l1 Y GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachP.Expression
9 V! }5 }3 ^! q4 F5 [% c 8 s3 V, X- N+ e" n- q' s
oIndexStr = "D" & CStr(index + oCurrentIndex)
$ Y! G9 h! L3 Y& w5 `5 x GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachP.Value 1 L: X5 f3 p3 F
Next
/ m A6 H( m* b$ |( h8 U
, I5 [- Y: l+ z% _ Q: P oCurrentIndex = oCurrentIndex + oPTableParas.Count
! `. Q1 o+ h9 @% D
, z8 b9 k5 W: u1 n) NNext6 @5 m5 [+ S" r; H6 R4 W% }. E9 N
, z8 u4 t! X. R e- [
'Derived Parameter Table e- X3 U o" _% M6 k: o+ C' F4 N Q
oCurrentIndex = oCurrentIndex + 1
# r4 F. T: m" _: pGoExcel.CellValue("c:test.xlsx", "Sheet1", "A" & CStr(oCurrentIndex) ) = "Derived Parameter Table"
3 u1 d9 E3 j' O6 M
8 W! i% L8 b ~. t5 z8 q& H Dim oDTables2 G6 }; B! _6 p" U4 x4 z. @$ s2 A
oDTables = ThisApplication.Activedocument.ComponentDefinition.Parameters.DerivedParameterTables4 m. s7 F6 t- L# T3 h: [
; K% C1 e0 Y' l& H1 v+ z" B$ c
For i = 1 To oDTables.Count
9 ^3 o* Q) D o5 @# G: i 4 |6 a6 \1 F1 x2 `: j0 N
Dim oEachDTable# D6 A( k5 |2 C Z% F: q$ z
oEachDTable = oDTables(i)
2 R3 e4 A8 b0 F: s8 S7 ?9 W# } e3 } * F' t/ f( S+ p4 n) @4 u
Dim oDTableParas f) V1 {/ x$ [5 o* C
oDTableParas = oEachDTable.DerivedParameters
9 J3 T7 @# \& p7 r, @ ; B! [' I' L8 w% k. e0 F
oCurrentIndex = oCurrentIndex + 1
6 ~' |% @2 S6 }; ?6 ~ GoExcel.CellValue("c:test.xlsx", "Sheet1", "A" & CStr(oCurrentIndex) ) = "Table Parameters - " & oEachDTable.ReferencedDocumentDescriptor.FullDocumentName
- o0 p9 g, t- d; M) u/ n( }
. U1 D, a' d) [) y For index = 1 To oDTableParas.Count! I" D p2 V) ]& }! Z+ y
. R$ D/ _2 b- T- r; Z& @
Dim oEachDP
, C! Q# j- S' v7 K S- T. B& m oEachDP = oDTableParas(index): P( ]5 n0 k4 I8 K+ s
- D2 D% @$ y" p5 |- t oIndexStr = "A" & CStr(index + oCurrentIndex)- b" A; m: a, t4 ]$ c% X2 g# O
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachDP.Name
( _$ O: T3 p+ {, B6 I2 j4 l
( y. D' E3 C& e oIndexStr = "B" & CStr(index +oCurrentIndex)
% s0 c' }" p. N GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachDP.Units; n* D7 h8 {0 _2 c
0 r0 `' V# V% q6 ]" m# a( N oIndexStr = "C" & CStr(index +oCurrentIndex) ) J) b9 n& W/ V" c' s
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachDP.Expression# }5 u4 y* ?2 l! o
& w( m" G8 X: A( w oIndexStr = "D" & CStr(index + oCurrentIndex) % K' \$ h1 }) A( T' t2 A( T* z
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachDP.Value
4 o! E* o- m D3 f! Q Next
3 A9 z: o8 R3 v oCurrentIndex = oCurrentIndex + oDTableParas.Count
3 R9 q% Z6 ]7 _
2 e) i/ ^ N/ x; pNext
6 a1 r, W$ ^0 O$ M8 B 4 N9 j( B* w$ k. y/ m& w+ `* j
O0 p/ N8 R, c& t ( Q! S% U J" f% |1 ?
GoExcel.Save
+ j/ E& J, M, s" ?" t qGoExcel.Close |