网上搜索到如下方法,暂未验证,谨慎使用
3 i' T8 W w. N1、VBA编程法--- Sanjay Ramaswamy6 C; Y5 q# X% v/ [0 D
: R8 F& \0 ]) P. |2 H# s
, V) W M: ~4 [7 D* z" s3 ^. F) M
: H/ i; l2 i: x" I% K用法就是新建一个空的Excel表格, 然后再VBA 编辑器里面复制下面的代码,然后add a reference to “Microsoft Excel 12.0 Object Library”。 运行即可。& m H q- d- Q( S, ~
) o0 v1 t, Q2 ^+ _" I* f# ~+ ^5 ]- g
9 V6 B9 Z6 u& j1 N o4 u& u& j# J, N$ o+ A- s5 u
Public Sub ExportParameters()
, c0 i! o# p7 [1 E: c* L+ @ ?7 ?0 `, _
4 P# ?: z5 M8 I' Q6 {
9 S) l, ]+ C8 I7 g8 B: o Err.Clear$ x. L F8 ?8 Z
u8 U0 l& I# I. _9 ~* p* l. p Dim oExcel As Excel.Application# l+ |. r( C: G! ^5 w
3 s8 X( I! l9 Z: e6 X! {
Set oExcel = GetObject(, "Excel.Application")5 H1 e& i. O! o' j" A/ l6 B
" t6 b7 ^' a, E
If Err <> 0 Then
+ `( B- }6 m, ]! g! { M* d
' @6 _$ r2 z% }* z6 p# J MsgBox "Excel must be running"; N: r6 G: x2 S$ w# ?- k4 \( k
) I" g) _! A4 n. p8 p9 x0 F$ y Exit Sub
# r8 L6 {3 O; t7 M; N2 A0 G$ [! o$ z& X1 f9 R3 n, N, P
End If1 j, W7 I4 z" F
) s" R9 d- Z0 d0 T$ B4 y2 s9 Y4 f
5 I5 T6 x$ a. A) r+ H
# w& Y% v. V! c( S7 L Err.Clear
" n5 [ I. s7 l3 ^0 X9 U- I$ ?/ m& y: {4 @) v' h& l" K: U: o
Dim oSheet As Excel.WorkSheet o6 T& e6 a, P1 ~. Z5 C
- R4 Z o0 C9 k, F$ D4 r6 J Set oSheet = oExcel.ActiveSheet
, P G' K# N6 }% \
3 ^9 k" q1 c- D If Err <> 0 Then$ D2 P R' M4 H V! g& |& ~
) s. H: H- H; i! K
MsgBox "An empty must be active in Excel"
8 l0 H/ }& \- }: O- \
2 b) |! u- \7 U5 \: A ] Exit Sub& y3 b: U0 P" M* F! g
9 t% h" z. t7 [7 ?& N6 `
End If. ?" _, r- K8 u8 E0 n. ]
, q" o: O) C& K( ?' a+ r. p
7 g/ v* o E6 {5 b+ @
% d1 w: R- P) w. n0 r Dim oDoc As Document
$ N1 Y$ p9 t9 n) M. K& q$ _# y
0 u! Q* _9 C* k- b/ T Set oDoc = ThisApplication.ActiveDocument
$ J3 X: A& Z8 y' x8 H5 G
0 l3 b' H7 d: B. _' b7 V w * b0 v; x3 g3 I5 @7 a+ @2 v
3 Q( B5 b, J1 K% b
oSheet.Cells(1, 1).Value = "Name"
: ~$ h* E9 s. }' d" r* L
+ j6 _! I8 A, q; Y G oSheet.Cells(1, 2).Value = "Units"
! ?# j# B3 a: I+ I7 X& ?4 n
9 B& M1 }% x2 A+ V oSheet.Cells(1, 3).Value = "Equation"; }7 z' L( C7 @+ `
- D$ e; {0 O3 x
oSheet.Cells(1, 4).Value = "Value (cm)"
4 {# W8 w' C8 E8 u2 v! g8 d
, w# l/ Y8 L& p6 U# n C9 M# v 6 ?2 A1 I; [" i5 U* A& f4 e
: [4 ?7 |) Y$ K" Q+ ]
oSheet.Cells(1, 1).HorizontalAlignment = Excel.xlCenter) {0 r4 S8 [" p. T
8 Y1 G% @% T/ M+ w! a, L
oSheet.Cells(1, 2).HorizontalAlignment = Excel.xlCenter2 a* l0 {6 ]0 z W$ h, H, @: @
) k6 G* B5 S; E! ~7 ?, X! M+ ? oSheet.Cells(1, 3).HorizontalAlignment = Excel.xlCenter0 ?& b- z: Z* [
* B4 S4 P4 d) p/ z8 y9 O
oSheet.Cells(1, 4).HorizontalAlignment = Excel.xlCenter: L, f$ p3 ^* @% ]9 S( ` F
# J* Q, U; t% U0 c3 ~
oSheet.Cells(1, 1).Font.Bold = True
6 z: n- U5 F1 s; C
; b5 p. p. L& z oSheet.Cells(1, 2).Font.Bold = True2 M" [5 |9 j: D% b& w, ^8 l% o
& R" k8 i, E; Z3 L) _8 m
oSheet.Cells(1, 3).Font.Bold = True
$ ?4 s! X7 B9 J2 ^% K- M v9 C9 K% S/ N c) o$ o, d* L, O! ]
oSheet.Cells(1, 4).Font.Bold = True: K7 y% u( P; _+ P: m
) `+ `, e2 |6 k$ |$ y! n) v
. w0 C6 Z# F7 e. D- s( t4 q1 c, P# X7 w: _; l* L
oSheet.Cells(3, 1).Value = "Model Parameters"6 L. F' [ {4 A4 ]7 ^/ N, G
! e7 _) m8 I, X0 u' |+ f; x$ e oSheet.Cells(3, 1).Font.Bold = True
N3 I; `# x; Y9 @& P B" Y' [4 d+ {! j+ f" o0 L
, F$ e$ r. u! l; C
- u9 s+ T5 U/ q* S3 h' e) A0 W' u Dim i As Long
/ k# U: ^5 J4 t8 W9 x
, P2 ^8 Q' l3 K( f+ `1 g' ]" Y i = 4
, z& d1 D, U8 F% u9 Y
: o1 H5 X1 Y N1 e! G3 A Dim oModelParam As ModelParameter$ S/ r0 E4 ?0 I4 S+ h8 H
) a/ A3 p3 A0 L3 p% V# L, A0 }+ h For Each oModelParam In oDoc.ComponentDefinition.Parameters.ModelParameters2 o: }8 W) q! M5 s5 \2 U- B% |! n
: z; X5 b* C$ i" v4 @7 M
5 k% E% R+ z; r( N+ M7 O3 F: i8 Z
( C4 M$ `6 L r4 c' ^4 @ oSheet.Cells(i, 1).Value = oModelParam.Name9 J/ z' v7 q) L5 b! ?7 C
z+ v! w2 ^2 T# Y/ W oSheet.Cells(i, 2).Value = oModelParam.Units2 N) l* ?$ Q. y' P+ Z( _2 f h
! R' l( f8 F3 X# @
oSheet.Cells(i, 3).Value = oModelParam.Expression$ C9 C1 E4 z- w9 [/ j1 X
: Z Q" E3 V6 T8 [9 X9 \& G& M
oSheet.Cells(i, 4).Value = oModelParam.Value
5 z" O* H$ h# l2 O" a( y; f6 {" h) g3 w, }' r: K
" v' ^0 c1 _# i4 R* Q% v" J
# ]* t2 U) T0 {8 h i = i + 1
/ H; b) y: x9 Z: f* S
4 o" s2 y* Q! l' @; Z Next
8 F: v" ?$ U" c0 I# Y7 I- f% I7 l, w. k; P/ x' `& x" l% {: E/ ^
" a, e! Y4 ^( M+ q8 n$ |- w6 L
+ Y3 g3 a# m. T% @- | i = i + 1: o+ C. j$ o2 x+ z# ~
: V" {! j2 W6 n, N, p
oSheet.Cells(i, 1).Value = "Reference Parameters"6 a) [- S4 Q! ~% i- t
% B6 _. O; b3 m
oSheet.Cells(i, 1).Font.Bold = True2 ]4 a! G* P. `$ G1 h: p
2 d& |" y3 [" ] i = i + 1! \0 x0 B1 n. a2 e/ q
* o- N6 k, o9 K" F, b
3 n- a3 r7 Y; b8 E* _: z
/ M4 F0 Y* h0 O. h; y! x" P& ~
Dim oRefParam As ReferenceParameter
2 n+ F3 g8 l3 w* L8 n
' {5 n: D2 W1 C \- S5 P For Each oRefParam In oDoc.ComponentDefinition.Parameters.ReferenceParameters9 S+ y1 S8 C# P
9 K! j7 ]. j; K( {8 |
5 I) w6 Q# P9 n# Y( a* u: }! z `# ~ T C" v
oSheet.Cells(i, 1).Value = oRefParam.Name% h8 Q/ V0 g3 P, m
j y' g0 h% _$ t7 R: A oSheet.Cells(i, 2).Value = oRefParam.Units
# B2 ^3 O! _: \7 P% D; x- L+ x* ?1 n6 H# _" x
oSheet.Cells(i, 3).Value = oRefParam.Expression e- a# w# n5 z2 |
( {$ m: p, b7 `; x" J5 D2 d
oSheet.Cells(i, 4).Value = oRefParam.Value4 Q2 l6 C1 n; M) }, [. Q8 c9 F
, H7 s5 \- g# D% T- t2 ` p
# _" S2 \' i8 K
2 I5 J; o' F* S: W3 G- y i = i + 1
q( h D% ?5 [7 r; q7 V/ i: |) M. P0 R4 d4 W9 s0 ]
Next' V2 C7 J4 ]9 @4 P4 |
6 H# O3 ^0 d! Y* m7 R' E& V
5 ]" s1 R- U8 m" x' P
5 w, j1 U/ R" w, S i = i + 1
/ a( W1 r& @( z1 p4 ?- y) H0 `" }# A
* y$ H" T) Y, [! E- J( l6 W j9 u1 } oSheet.Cells(i, 1).Value = "User Parameters"( M( p7 c7 ^3 k# C# k" z' f+ A# ?
/ f2 Q& `' @$ g3 g9 l! ]
oSheet.Cells(i, 1).Font.Bold = True
7 e3 k$ A( H2 M' M. I8 U5 |% J' v* F# M$ ?- v4 |1 G: f
i = i + 1
+ N6 K: o, {8 [2 T% I' Y
: X0 C A6 J# K, U
% ~3 Q; m5 J ` l' }( O6 \3 P6 Y8 d3 n' U
Dim oUserParam As UserParameter
' M. ]( \0 U0 E. F3 ~& ` j4 U: ]: j8 Y! y$ v& t7 U T
For Each oUserParam In oDoc.ComponentDefinition.Parameters.UserParameters
3 @! k- U% B, f3 o* D) N7 q# G @& {2 t* [
9 n8 [$ {1 e& ]) ?5 [
9 |4 s% w4 ~8 }! H' d oSheet.Cells(i, 1).Value = oUserParam.Name! k) w0 j( k3 u/ l( p; h4 j
( a _- _# d0 _3 w' V, m
oSheet.Cells(i, 2).Value = oUserParam.Units8 x2 O. b x4 K
, Q* ]0 a# [3 I0 q$ K
oSheet.Cells(i, 3).Value = oUserParam.Expression
+ C$ D! P$ H$ _. @' ? [. ~4 E) M
& x- H+ B6 C8 B1 o9 Z H+ g oSheet.Cells(i, 4).Value = oUserParam.Value
" V' }' S6 w+ q9 d) z0 q
8 l) G! U# S7 l P! m9 f3 p( P p0 d/ G, |- n7 I: }* `& R
# B6 O- B0 C2 n: ~# `) [2 T
i = i + 1
) j+ V( x, C4 h$ t. ]) F/ c" F/ g0 X( ]9 B8 S; G5 R8 ?6 Q+ D
Next+ h# }+ t+ K: L) z' |5 y; a
; q# F ?4 u/ x' o6 `/ T$ B
' d) H p- C2 z9 P: b
) I1 J7 l. j, ^3 M9 k3 j Dim oParamTable As ParameterTable
6 B" M* j& y2 F0 d% v" c4 z6 e' @8 [+ c6 V7 v0 t
For Each oParamTable In oDoc.ComponentDefinition.Parameters.ParameterTables
+ S D6 O: G' e) U& }3 i( g1 ~
0 k0 q" h/ R3 s8 D! S
( }, G3 B& r% S: b$ [
5 [; K0 p1 _! X" ~& v' u i = i + 1
7 G7 x& F2 k* M# h3 K* O: O3 p& Q, `
9 G& f# r2 F3 P& n oSheet.Cells(i, 1).Value = "Table Parameters - " & oParamTable.FileName+ u" [6 a8 X( i( O
& ]" _! |" s8 u8 m% U oSheet.Cells(i, 1).Font.Bold = True. `6 U7 F/ y* W! V0 y& ~( ~* `+ V
4 j# A7 ~" {8 e7 c i = i + 1# {( I/ Z' G) i0 g( E
1 a5 x8 y$ v) I# H' {7 M# x: B& c( T
6 M9 e. R1 M- U _0 X* R
4 }) Q3 S2 G. e( f Dim oTableParam As TableParameter
$ L7 O% G( y8 v: L
, T2 T; L: ^2 C For Each oTableParam In oParamTable.TableParameters2 y4 O$ f2 V3 X, j5 [
* I8 f5 u: a! ~( _, W
* T2 Q6 p( E" W
$ G1 Z, i: A& G _" Q) } oSheet.Cells(i, 1).Value = oTableParam.Name$ P \# S0 o" O O7 J3 V
& @2 Z* j5 S4 k+ h9 P @; F
oSheet.Cells(i, 2).Value = oTableParam.Units p, Z' b! m( I7 t4 k+ F
4 C: [) U6 o6 B0 X c m oSheet.Cells(i, 3).Value = oTableParam.Expression
6 a0 ?$ c4 i6 R4 k2 p7 i0 U4 C( ?% [' p' X0 A6 e
oSheet.Cells(i, 4).Value = oTableParam.Value# y/ I# I% x( d1 T( R
: l7 Z" s# \/ V " v1 n1 ?6 n- l& g7 k
! z" e% N, v. ^
i = i + 10 C* C6 f( z4 F$ m& I0 Q
; F ~" Q7 L' Q. I9 g+ F7 T! Z Next1 a8 e4 B# b. D- F' h
8 ^ W* O" o! B% l' l$ V* B4 D; d
Next
# H5 j4 F9 V, [* d: @0 s) q: g9 U( y/ r% S: V
5 k6 f. y/ n- w# X8 \
" ^2 m* u3 A; b7 ]- N Dim oDerivedParamTable As DerivedParameterTable" C& ^/ }/ b" y% {+ S! ?( w1 a$ O
1 x+ [. Y0 D/ z( ?* r For Each oDerivedParamTable In oDoc.ComponentDefinition.Parameters.DerivedParameterTables
2 g K% X: h* i( h2 q* x" I d9 s8 ^/ J1 E* D5 r/ L3 j( ?
( J' G% F; l" i# E8 w3 O& V+ i7 c
i = i + 1' v0 g, H1 ?$ K" W+ {: ?
1 f! v5 t5 f; U( n oSheet.Cells(i, 1).Value = "Derived Parameters - " & oDerivedParamTable.ReferencedDocumentDescriptor.FullDocumentName
. }+ p3 O- J. G+ d/ q n$ j! b, h+ f# `# b. q" T2 F: }
oSheet.Cells(i, 1).Font.Bold = True; h) K8 v7 T1 t0 {+ K
' m- v7 n7 j4 u- s6 j! b3 c
i = i + 1
/ F- ` \) R; B' f2 v7 n" M5 b
' f* D) e+ D0 {3 i2 M s , Y" w" r9 T. e3 R
0 y$ ~; d3 ]; Q8 n
Dim oDerivedParam As DerivedParameter
7 A7 W( o0 i; T% w& T
0 p) t# m4 Y! W& O9 @) ^ For Each oDerivedParam In oDerivedParamTable.DerivedParameters
& r; F- ]& t6 l7 \+ N- W5 K ]% q1 _$ u
8 G1 B8 Q& w3 M7 c( q" L
( O0 }# b: Q" u/ A' I, r oSheet.Cells(i, 1).Value = oDerivedParam.Name+ m( y% x# T2 Y% X( t$ l
+ }1 W" n l* y7 n; a) p) c
oSheet.Cells(i, 2).Value = oDerivedParam.Units2 l8 h- W1 V8 X' k [2 O, L3 ^# P
+ x+ H! z8 }: Y' ?
oSheet.Cells(i, 3).Value = oDerivedParam.Expression, q, W$ |$ ]: X* F8 n O
* F5 w m* g- S4 e H% b8 E! K% L( F
oSheet.Cells(i, 4).Value = oDerivedParam.Value7 p: b$ Y8 m! ~. D5 N0 W: k
7 @4 m1 k% i$ b( l. t9 d" y$ P # G( t. y: m4 j. F' ]9 d" m# u7 Y
) X2 j* i) @ R+ }* z: C; C3 x1 s% @ i = i + 1
, {, N! Z7 V o" Y/ Y% G' ?" J2 Y0 l; \/ o$ m4 T/ W; w
Next
9 f/ b. @9 v. N+ K5 J" h5 c" w, c4 c x% c7 M
Next
% Z2 d* J; L9 C* q8 B: A( H3 \5 w9 }0 M m: P g D8 Q
End Sub! {; F! A: r2 J
# h( x- \' m; B1 Y 6 T1 m: Q4 w0 I) S
6 L( W5 @9 [& i' P" s
" _3 Z9 L0 A0 x% w. U2 [1 N
6 E2 H1 O" U/ s第二个方法--- iLogic方法 , 感谢xiaodong Liang
8 Q' K, W0 J( ^. d) P% ]+ V8 q3 P! P
" ~7 L9 K4 X/ J9 p7 g: _
# }/ I T( q! a, a# f9 s4 \
用法,新建一个test.xlsx在C盘下面,然后复制下面内容到一个规则里面。运行即可。
7 o, z2 d$ ~4 Q+ n7 R6 Z3 O; z6 S: c+ Y- I. H1 {0 K
I+ B5 E% L" b2 [0 D+ x( I
2 @4 R! j( Y8 O$ e
) O* d* j, X% ]7 B
5 ]& _' _# R% ^4 C! `2 ~% y 'Open Excel3 a3 D" ?* N. k! y, |9 `# j
GoExcel.Open("c:test.xlsx", "Sheet1")" O$ ]( g7 Z4 x8 u
& \) d! a0 {, E) Q! Q3 R
'Title of column" t( g% T: d4 ?" y5 H1 k+ v
GoExcel.CellValue("c:test.xlsx", "Sheet1", "A1") = "Name"+ |' b* }# |3 |3 z+ G3 e: [
GoExcel.CellValue("c:test.xlsx", "Sheet1", "B1") = "Units"2 l2 X) y% c# K' A3 y
GoExcel.CellValue("c:test.xlsx", "Sheet1", "C1") = "Equation"2 x' G/ {! q' j+ u/ b/ g2 _
GoExcel.CellValue("c:test.xlsx", "Sheet1", "D1") = "Value (cm)"* h& M+ ]; k+ i/ U k8 U
8 ?$ H1 Q2 T7 I' v+ H. M& | 'Model Parameters: i( l2 S Y6 l, J8 d
Dim oCurrentIndex As Long = 3
: M& b4 e: h- v9 {. p: \$ ]8 b1 a GoExcel.CellValue("c:test.xlsx", "Sheet1", "A" & CStr(oCurrentIndex)) = "Model Parameters"
2 k% ]3 V& J) @
% n5 b3 C: t* D' S Dim index As Long
' L) n# [( y9 G! ]) m" x+ [ Dim oIndexStr As String
, b/ d |: N" P: }8 t. s
4 P3 f4 b- \( f: A1 w( j4 R Dim oModelPs0 d, R! d( F) ~5 I$ e
oModelPs = ThisApplication.Activedocument.ComponentDefinition.Parameters.ModelParameters
( A2 ?0 O& d* l" [2 B7 T, K6 a7 M, Y0 L3 x$ Z; k
For index = 1 To oModelPs.Count
3 e t) C* u1 \
, g9 l( [5 K+ U) N3 M' T 7 r& o7 g! d/ P5 i
oIndexStr = "A" & CStr(oCurrentIndex + index)
# o- ]$ j/ g$ L) t- M GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oModelPs(index).Name
, ?$ f* D \3 W3 R3 k6 I7 K3 I! O / z, r1 W) f. e$ H! ^8 \
oIndexStr = "B" & CStr(oCurrentIndex + index) / e8 T7 F' h: |, x
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oModelPs(index).Units. w7 O! A6 E: K$ Q6 I# V3 @
! J3 r) a- g; d5 X1 h
oIndexStr = "C" & CStr(oCurrentIndex + index)
; B5 @6 j! g- [$ S% f$ `( | GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oModelPs(index).Expression
# d+ z0 I' \& L# Y) x 2 y3 p$ l5 n- d" }- U* N$ r
oIndexStr = "D" & CStr(oCurrentIndex + index)
+ h2 D! \) y8 q' U4 u0 O8 ~ GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oModelPs(index).Value- u* s# x7 \/ C
Next
2 l! ^% C5 ^* H6 b" q
. A1 \% l! P2 M9 f$ A% X8 o) Q'Reference Parameters
. F* |) u8 r2 y' F2 Z: VoCurrentIndex = oCurrentIndex + oModelPs.Count + 1
, U" C9 _0 F, e+ h0 ^GoExcel.CellValue("c:test.xlsx", "Sheet1", "A" & CStr(oCurrentIndex) ) = "Reference Parameters"
& [! ~" h% @1 |. O3 O0 n1 P& U- T5 ` . A, Q& ?! S. ~. F+ K# W
Dim oRefPs5 F0 {% L# O Z5 n
oRefPs = ThisApplication.Activedocument.ComponentDefinition.Parameters.ReferenceParameters
" p& F2 T( S3 F# y 8 s7 m. ?. ~! ^( ]3 |9 B* j
For index = 1 To oRefPs.Count; G7 e: v7 V- C6 [
* T! ^- }( C* F0 C2 m oIndexStr = "A" & CStr(oCurrentIndex + index): s1 E2 V) B2 q
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oRefPs(index).Name
# P8 N4 j( }. ~2 C# ?4 E( {+ u
) X8 C5 U' y+ N3 b oIndexStr = "B" & CStr(oCurrentIndex + index)
/ p9 ~6 v5 l! w. H0 c0 }! O- K; E GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oRefPs(index).Units! i" S( N, H1 d6 z( K
. K1 ?. U; |+ g0 B4 ~( `- D oIndexStr = "C" & CStr(oCurrentIndex + index)
* _, q& E `2 r9 Z; o2 v7 C GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oRefPs(index).Expression0 ^) L6 T9 k% O2 A% ]/ [
& K3 L B; S/ j3 F
oIndexStr = "D" & CStr(oCurrentIndex + index)
: E2 [" J1 }# o3 ] GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oRefPs(index).Value! n x/ c/ C) B1 u
Next
" A; u- J" J# d6 F8 R3 b& V
* g+ N9 ^9 L, B- R. j'User Parameters
6 L6 U1 N) d) {0 a& eoCurrentIndex = oCurrentIndex + oRefPs.Count + 1
. M/ I( X0 a% ?) h1 P! ZGoExcel.CellValue("c:test.xlsx", "Sheet1", "A" & CStr(oCurrentIndex) ) = "User Parameters"
5 B. J4 O2 O6 P- A9 Q1 N$ M4 |2 N) g5 J$ I H4 D
Dim oUserPs
/ c; @7 ?% Q& BoUserPs = ThisApplication.Activedocument.ComponentDefinition.Parameters.UserParameters/ f# \1 t+ I7 f. m9 j
# `) H4 Z; B9 b. F; A p( ~For index = 1 To oUserPs.Count
1 `0 i& W [; A3 {: X U% h% U# r7 R
oIndexStr = "A" & CStr(oCurrentIndex + index)
" J2 ^3 w' `) K/ r& x! e$ G5 F3 s( N GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oUserPs(index).Name: a% ?+ ?3 K6 A' m. ~
% g5 a- Q- |" @( I# U+ [" ~9 [
oIndexStr = "B" & CStr(oCurrentIndex + index)
: e6 P& \! A8 Q/ a1 u) s GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oUserPs(index).Units; |' ]4 }, c1 e- A; I
g) U9 e0 _* A2 [* b1 g: C
oIndexStr = "C" & CStr(oCurrentIndex + index) 7 E7 S" Z+ i3 O2 |7 }; C, u
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oUserPs(index).Expression: S9 x6 M7 H3 k% Z
$ |! @ N5 v% K oIndexStr = "D" & CStr(oCurrentIndex + index)
; H/ T" R& V3 M. u4 i( n' x0 @* T GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oUserPs(index).Value% F7 }' _3 M$ Q+ \
Next6 V' ]' e% q: f, p% a( U
. L E# Q- \! p: m% b8 L
. u/ N, W2 y2 q/ E! T o
'ParameterTables& G# F7 p) T c9 L3 {/ U4 Z# _
oCurrentIndex = oCurrentIndex +oUserPs.Count + 1
. V7 [* B8 I- q0 k5 B( K8 xGoExcel.CellValue("c:test.xlsx", "Sheet1", "A" & CStr(oCurrentIndex) ) = "Parameter Table"& l% Q& _% o5 k" x6 R! Q4 [9 n
5 S6 ~) J/ o/ X& L* e" nDim oPTables7 E0 s) e( S6 Y7 [; U; O
oPTables = ThisApplication.Activedocument.ComponentDefinition.Parameters.ParameterTables
% [" i0 J/ \/ t# i8 p9 b) M* V: M2 y6 D. _
For i = 1 To oPTables.Count 1 l- v+ {8 z- ^% v
4 h- a0 Q7 G8 t
Dim oEachPTable- O+ r/ j+ N7 ^; F' l S8 g
oEachPTable = oPTables(i)
( i; v1 w, W) p+ E& ?* e 6 X! v6 r1 h" d/ ^) D) |& b# U3 Q
Dim oPTableParas z' C0 m3 K7 N3 K
oPTableParas = oEachPTable.TableParameters
) @0 o3 `# S" S9 @# t ( f' W# s- g5 h4 y( e! l
oCurrentIndex = oCurrentIndex + 1# E/ y( G3 P* h9 s
GoExcel.CellValue("c:test.xlsx", "Sheet1", "A" & CStr(oCurrentIndex) ) = "Table Parameters - " & oEachPTable.FileName# x5 V) _8 O1 r5 b2 I% e( O
: j9 s) D6 Z# k; \4 K
For index = 1 To oPTableParas.Count' L0 f7 X* X" _9 ~! L2 G* `
2 m' {9 m9 Q4 t+ N Dim oEachP2 z- b2 ~4 W' f! {; U% D' i ^# J
oEachP = oPTableParas(index)
9 Z. y2 @- [/ P7 V& } t) p& N. o( s B* S+ @2 b3 r; J
oIndexStr = "A" & CStr(index + oCurrentIndex)
, {* X+ Q7 }" f' k) N |% A GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachP.Name. _! L! Y5 T# @* p3 I8 G1 \
# x: u: V2 Y, p! m' Z2 a* E
oIndexStr = "B" & CStr(index +oCurrentIndex)
" I3 K( t# H2 t9 y. | GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachP.Units) M. ~9 F5 b- ]/ s6 X3 n% \( [, I
! u. B: B6 L4 J! m; O
oIndexStr = "C" & CStr(index +oCurrentIndex) 2 o8 n9 X' u& A3 O. i- K* t b1 u
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachP.Expression9 K/ G5 @" C, R# y
. ~7 S9 [/ T0 c7 L' q$ ] oIndexStr = "D" & CStr(index + oCurrentIndex)
4 F6 w$ C4 ?& e/ K GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachP.Value * ?. Q$ N$ Y5 ^" C T8 R
Next- ^6 L4 f0 b* R4 K
9 i6 u9 D2 Q2 V# n p oCurrentIndex = oCurrentIndex + oPTableParas.Count0 p \8 f( O) y
4 F/ F* s4 r4 ?# B7 [9 z" J8 m
Next8 P. U2 O' _" U& |
1 a4 q* K" c: |
'Derived Parameter Table: \; h( ^+ X& L
oCurrentIndex = oCurrentIndex + 1
8 S& e4 i W0 `& }* H3 c6 z+ gGoExcel.CellValue("c:test.xlsx", "Sheet1", "A" & CStr(oCurrentIndex) ) = "Derived Parameter Table") v3 J( B& L8 {" K% X
% Q, l2 g5 Y9 ~4 ^ Dim oDTables! L5 g! K7 d0 G4 @& [3 W! C
oDTables = ThisApplication.Activedocument.ComponentDefinition.Parameters.DerivedParameterTables
& w/ Y3 [8 z3 W6 |4 p9 I* ~% |# j2 F. R; d
For i = 1 To oDTables.Count 5 O3 U0 Y9 p* y Z d
8 N" u; l8 U1 d+ F/ F! \: l Dim oEachDTable9 |2 s+ g7 ]0 Y
oEachDTable = oDTables(i), F9 ]( b9 w7 Z/ n, Y! g
2 E; @+ [6 z# E2 Q6 w, G8 D4 {
Dim oDTableParas
; F& I6 H: r" }3 j* X oDTableParas = oEachDTable.DerivedParameters 5 j0 O7 \2 t8 h- F
% U1 _) n5 U1 Y oCurrentIndex = oCurrentIndex + 1
# c5 L/ ?9 `- _, L% ] GoExcel.CellValue("c:test.xlsx", "Sheet1", "A" & CStr(oCurrentIndex) ) = "Table Parameters - " & oEachDTable.ReferencedDocumentDescriptor.FullDocumentName" ]9 w- e P' E3 |" y. D2 }7 z
4 `8 @; ]( y( S# k+ X5 A
For index = 1 To oDTableParas.Count* a' u( N& k G7 I9 q5 @
5 ?4 v6 S& k+ l" S
Dim oEachDP% V. y; ?! p2 s2 c8 u7 @ F z
oEachDP = oDTableParas(index)
9 e# H- z" r4 @& H+ [$ ]5 E+ H$ P & |- Y6 d8 m# s! ]& c
oIndexStr = "A" & CStr(index + oCurrentIndex)' l a; e+ F9 m/ U% P
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachDP.Name
& V2 U5 c0 O) Q: E! f! Z8 J. m - M- a4 l) `1 U! J1 ~; [
oIndexStr = "B" & CStr(index +oCurrentIndex)
- P" O- } f" |+ ] GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachDP.Units6 B/ L7 Y8 \* a7 |& e' d3 P7 E0 S$ T
, p$ R8 ^0 {: T4 x5 Z s: Z, b Q oIndexStr = "C" & CStr(index +oCurrentIndex) ' n- T8 W' ]2 `
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachDP.Expression, G! T3 P" H+ [9 K/ n7 P) |
$ W- E) h0 V$ [/ V
oIndexStr = "D" & CStr(index + oCurrentIndex) " A% o( ]- E9 Q! b& O
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachDP.Value
" [! H. V) q# ~6 G3 N2 i* T. ~) _ Next
9 t! w8 F. B# Y4 k! L; U6 v4 S oCurrentIndex = oCurrentIndex + oDTableParas.Count) c6 B" X! G2 M+ s+ y% l6 m: x' W
. g2 k( [( f' l4 \0 x$ ?! }1 ?- t+ H4 v
Next
7 K1 T. t& g2 H7 J) D7 h1 _
7 x% C# B' S/ Z8 `1 J8 \7 {
" u ?3 ], _' F1 H7 T' E
# J' q' n# ?/ d9 z- J' w6 gGoExcel.Save
3 ~1 V: z9 ?* A* u8 J: l" Q) U( WGoExcel.Close |