网上搜索到如下方法,暂未验证,谨慎使用
) M- T( M; ]6 N* E( P( p1、VBA编程法--- Sanjay Ramaswamy
6 c9 t2 c4 o# @ G' N3 W' F! i3 Z6 [
' `8 A7 F5 w5 L9 J3 E0 r, N: R
. F( |" K h' F2 H7 l5 A
用法就是新建一个空的Excel表格, 然后再VBA 编辑器里面复制下面的代码,然后add a reference to “Microsoft Excel 12.0 Object Library”。 运行即可。
; Y( I9 c- Z6 V3 Z- H( P8 }+ \' q% Q) c, J: \. ]+ W$ K
# ^& ]( @$ _1 J( h f
0 }& X# J3 J( }8 a4 y# f9 c
Public Sub ExportParameters()+ V% |) X u; A0 c7 z. M! B4 P
& h4 F) @, H X
, B, j) a# ~ M# P/ e
& R' r0 P1 v9 v) v! k
Err.Clear
3 E/ e* q7 J S& G
$ {5 f# y, Z* E# w( z; \" u; S/ Y Dim oExcel As Excel.Application) f) t+ _% E9 [
7 W; \7 A; M0 _- ?" Z: c Set oExcel = GetObject(, "Excel.Application"); c5 s! ?! s) ?4 F% [
z p. c7 N& M- D
If Err <> 0 Then
5 e+ q' v3 ?% w, t# h( u* q& V! k1 s4 n9 ^# h
MsgBox "Excel must be running"
# d3 h2 ^: y6 z4 J9 h+ Z
8 c( `9 R% X+ k Exit Sub/ g2 n/ T, f/ F
7 G$ r! U6 e9 R3 @3 \
End If
' L% A6 [+ I1 J8 B! i! i& C. l
) v/ p! o' F& m9 l9 z) f# m ! F0 X9 J+ Q. ?5 p, U# x# L, m
; y- J6 X* ]7 s% f, l W Err.Clear
8 Q1 D4 Z0 u; m: C6 Z* p& y% @1 @' a
Dim oSheet As Excel.WorkSheet
: c/ G7 q( Q! m' p
: a' H" O8 x; {! m6 ?: o+ r2 l Set oSheet = oExcel.ActiveSheet
4 q, G3 ]% W. w4 `3 ^) h/ g; |1 i. h! J- G; A+ T1 \+ U5 Y- `3 }
If Err <> 0 Then& e- `; k* E r8 t# L) U
2 s8 s1 s: p5 U2 X MsgBox "An empty must be active in Excel"5 S( }$ O& w' t8 d% Q3 R6 I
' X3 E* G. O8 O' \( o
Exit Sub2 i* J! c+ l$ W# E
+ }$ j2 }' x: P6 j$ E6 h End If
- H8 b9 I3 L: G |; \0 g3 l. r; ]
( R2 U/ B3 k8 w$ P& ~; J
, F8 M/ ]0 j0 r5 }$ f. l9 L; m0 N) S
) W4 K1 F1 S* @* ^5 U Dim oDoc As Document
% L6 y8 U' X& B' ?$ G, r5 h$ e. P; k8 _! a; {$ R/ x, K
Set oDoc = ThisApplication.ActiveDocument
. E' k6 }: n; r+ k. h a/ D1 f0 R: K& X, [
3 I+ Z+ P$ ?1 x3 Q. Y: G
; ^$ L+ `% y0 p; ?0 j( m
oSheet.Cells(1, 1).Value = "Name"1 m7 l. @) T4 i- H, k
, g% ]4 A" F. V$ [ n
oSheet.Cells(1, 2).Value = "Units"4 N- h6 b3 r O5 t
4 \9 ?* {0 n: Y1 ~
oSheet.Cells(1, 3).Value = "Equation"
) N+ K/ u% f' s9 |, C& C. n) D C5 Z" l, i7 N' _
oSheet.Cells(1, 4).Value = "Value (cm)"9 ~! H7 A3 t$ ~: k7 j1 P
; ]- Q7 ^5 T- G1 a
& k2 {/ F7 p& m4 X" _- H8 [
+ _! p6 H7 I: U oSheet.Cells(1, 1).HorizontalAlignment = Excel.xlCenter
% \) c# q1 L; N9 ^2 i; q9 Q; N+ c5 ~9 r0 G+ \3 S7 E
oSheet.Cells(1, 2).HorizontalAlignment = Excel.xlCenter
! P/ E9 ^2 z. Y2 w2 A' j; {1 v4 I8 q$ ^: @! Y6 K, o, m
oSheet.Cells(1, 3).HorizontalAlignment = Excel.xlCenter5 x3 b' c: q) U7 R
- Z$ i9 I5 R* E& r# ]0 a oSheet.Cells(1, 4).HorizontalAlignment = Excel.xlCenter. z+ u, v; I4 E
9 n. O" ]' K I4 Z- m. q8 C
oSheet.Cells(1, 1).Font.Bold = True
: u( v4 w1 L' E- M3 V/ R' ?+ F- T1 s$ {
oSheet.Cells(1, 2).Font.Bold = True
' `5 o& B6 [. d9 ^3 U( o8 h4 A( ?. T1 P
oSheet.Cells(1, 3).Font.Bold = True9 W* a4 L W$ x: V3 }6 U/ h# h5 f/ J3 Y
( @, e: S. U- ^2 a6 z. y oSheet.Cells(1, 4).Font.Bold = True6 U2 K* m/ O( v5 ]7 B: k, ?9 n
) ?8 R- i3 @ v" S/ ?) G0 {, e/ `
' `& ^+ F: t4 A
9 C! T7 f- g( f4 ^; n oSheet.Cells(3, 1).Value = "Model Parameters"
8 p: G3 N$ W' i9 K- x4 K. C# ^* Z" Y: U
, C/ Z4 y. g) F oSheet.Cells(3, 1).Font.Bold = True
$ w) V, R; w$ K- w0 ?& Q$ ]* ?2 T. j
& g9 R H% |' _6 [* j$ X( |$ q: h) y" ]$ S! P, L
Dim i As Long
! B' n( Y! S) T7 v: ?% Z0 V/ p2 F7 u4 f0 f
i = 4
: Y* s! X! \2 N, u$ N, B
/ _, r: l, [- U. m2 ^" Y Dim oModelParam As ModelParameter' H( T8 e0 v! b. T$ c
+ }; g0 N; `5 ]' k% C8 c+ h
For Each oModelParam In oDoc.ComponentDefinition.Parameters.ModelParameters
- |- y8 C: k0 m, e- ^# [+ A
6 Y. b0 O" g+ v. x2 O: W, W: D
% U! I. v0 {2 Q( v2 i4 F3 p9 n7 I$ u& Z% e; E! m
oSheet.Cells(i, 1).Value = oModelParam.Name
; t' t" Q% `2 d2 A" A) @
" G/ t! m( O* C3 ?) u oSheet.Cells(i, 2).Value = oModelParam.Units
% W z! F$ Z; R& [0 }7 b, y7 ~) l( Q# {/ J
oSheet.Cells(i, 3).Value = oModelParam.Expression+ p! C! v3 s" R S
6 k/ ^: g/ i- u: q- _' { oSheet.Cells(i, 4).Value = oModelParam.Value
9 |* ?+ R a1 I5 U
: P l, D2 `) M8 E, T7 R# J I4 s
7 `$ U8 P2 I1 Y1 h; W$ _2 d
% X7 C a2 r* c4 A i = i + 1
( M! W/ _- i6 e' h; s# }$ M
' |- y& z9 C( J5 j Next
+ k9 Y' G9 G- c7 I5 M' {( M3 }; {1 g9 {5 V, G
' w4 A2 X8 j2 c
3 ]) b1 D' M+ W! T% A! I( h i = i + 1" Q8 f5 v) b% x/ q
& v8 P0 h7 q! j
oSheet.Cells(i, 1).Value = "Reference Parameters") r0 ?6 j2 T [) O4 P
5 H# \7 a v7 H- ] oSheet.Cells(i, 1).Font.Bold = True1 ]) y* h/ [: j8 h8 {+ d! v
3 k0 R1 j; l1 q: g, ~+ e i = i + 1. Y ?: u/ `2 W' }
0 M! q. P1 M+ \$ M$ G5 ~9 G- r' ~
' j6 y, d9 A, x! R5 c% e% g: `: q) k p+ C- G7 `8 n& k" @
Dim oRefParam As ReferenceParameter
" i/ ~; [- U3 f% ?9 _) v0 f
0 N- n; i; o W. M; ? For Each oRefParam In oDoc.ComponentDefinition.Parameters.ReferenceParameters
5 N# e9 }% H7 n( l
5 j4 J! c, D7 W8 C ?% D7 G: t $ N3 R) B/ F+ ?5 W
$ [5 x8 I: |) J O# m oSheet.Cells(i, 1).Value = oRefParam.Name M! t( ?' Q# s! G+ c2 e
7 s. ]2 h8 W' \. Q
oSheet.Cells(i, 2).Value = oRefParam.Units- t) `3 n+ }1 g; r- I+ M6 a; F5 e
z# G: c* I/ v9 \* R7 ?8 A( N oSheet.Cells(i, 3).Value = oRefParam.Expression
/ l/ P$ b; y6 B7 W
7 j! m# d9 P9 _4 [! @/ g. W oSheet.Cells(i, 4).Value = oRefParam.Value$ |8 W! P, C( ~6 [, q* A
1 \* B) j' _" I7 T5 g5 G2 e( F+ G
9 b- B5 L' n6 }7 t# A5 r0 A
" b* p+ Z( G$ }6 H' n i = i + 1. ]' L6 o7 G' Z* m0 O' ^7 V4 O# T: Q
& I% w0 L3 j; ? Next) s9 l% S8 y5 V5 D# ]+ _. W! l0 U) H
7 _ ~4 m) K+ H$ ^# p . Z7 V! m4 x: z& ]
/ T9 H: b- S, B2 ^0 x i = i + 1# k# Z8 U$ _( z+ s
; T# ~# j+ }' W7 M/ N- L
oSheet.Cells(i, 1).Value = "User Parameters"
9 d6 _& k5 V4 C' {( U
+ }- @8 s, E3 N oSheet.Cells(i, 1).Font.Bold = True
, i9 I: h1 E& g3 o# }9 ~) E# h1 A( n+ N& G4 e9 N& g7 q4 o1 K5 j
i = i + 1
2 y) C/ `8 y1 b% y% p( G# t' Q1 d' j E8 _7 _
L7 b/ }9 Q9 t4 g( h& f2 k3 ]8 x" N+ {# s3 I* l' J; k
Dim oUserParam As UserParameter8 p: W: f% s. |* }
& C4 f4 H7 _: `3 }
For Each oUserParam In oDoc.ComponentDefinition.Parameters.UserParameters3 x v$ A# w' M
3 c- a" i' y* t
! t/ b6 B9 P( K2 y3 E: l4 C
7 T% v1 m& ~0 d1 e8 c" X
oSheet.Cells(i, 1).Value = oUserParam.Name
: F5 u, n/ L% x& _4 j- X/ v+ R+ L t' f. S. L) y: m; e" R
oSheet.Cells(i, 2).Value = oUserParam.Units
$ n( w1 C- @8 |
/ J. P! B/ K6 Z, J/ ^% z oSheet.Cells(i, 3).Value = oUserParam.Expression
8 H$ \# B5 [2 [& y; W4 w5 q6 }: N% x$ F/ ?
oSheet.Cells(i, 4).Value = oUserParam.Value
) x$ `) x2 s/ S$ F- o0 H- K, X7 i5 b
! H8 s0 x. ]* X0 V" B
! c; ]- Z/ c4 y9 f# o( M
* l$ m: ?% X, o i = i + 1
8 Q1 _% ^+ [* r( F5 d& f) U$ F+ _ }4 I- P- P
Next9 r7 u+ Q# q' m" T% b& D
- d5 j, F+ W" u' Q
# K/ P( m( b4 E3 F
% K. p& _* V3 S Dim oParamTable As ParameterTable
" X7 a3 L: c' |- |6 [
( C# _/ D$ k, D h6 [: J For Each oParamTable In oDoc.ComponentDefinition.Parameters.ParameterTables7 `7 n9 d N$ H- E6 `; ^; H9 h
' b" u& o) u: Y7 {9 q. d# ]3 \" n
5 f* U1 r! _# y+ H- a o8 k9 c& ?
: W1 a0 ?3 x2 I* f/ m' L3 K; u6 g i = i + 1( p+ w" Z% u6 p& i
5 P# z/ S" v# r oSheet.Cells(i, 1).Value = "Table Parameters - " & oParamTable.FileName- h* l+ d* h* H% U! x9 w6 ]# P
) L) S) ?5 l, r oSheet.Cells(i, 1).Font.Bold = True+ }& h. L) U* f% C
8 c- _2 |; z% ] i = i + 12 f* H- a6 D- j
7 q, w- }* |- d$ ^3 a
. l3 g( q% M" L- z. ^, X& f- L" @" I$ t. U; Y+ I4 c: J) i
Dim oTableParam As TableParameter* W5 ~( x8 y Z# t( H8 n. [
7 X K) M1 \1 c* ~
For Each oTableParam In oParamTable.TableParameters8 o% D; Z! t1 B/ e" }9 d
3 c1 z N% \/ U. d
9 p4 h& m$ p/ }0 Z$ D, H7 ?+ A+ u- h( n5 N
oSheet.Cells(i, 1).Value = oTableParam.Name
- U9 P9 P" o, J% {7 F8 I2 N5 j6 H, ~+ j
oSheet.Cells(i, 2).Value = oTableParam.Units/ D) M9 k* }: N- t
6 U7 t5 G, y8 {5 T G
oSheet.Cells(i, 3).Value = oTableParam.Expression# R- {% D7 B1 ?1 T S6 |
1 c% F. _+ t$ M6 Y. [$ H oSheet.Cells(i, 4).Value = oTableParam.Value
- C7 j# Y0 h, |% Z4 s# l) r; \; T6 y
8 |: n0 m( Z( R% ]. z( x" b# v3 P* Q
! H! C& k) k, a5 ^) F5 V& H+ Y$ J/ p i = i + 16 U, \$ b9 \" x8 ~5 w6 n
! j$ n. F' x5 B* I
Next; a7 a) b' s5 _2 ?# P$ L
- l9 T* @* i& y2 q Next+ Y! o! e; E) h& ?+ q, K b
/ O0 F6 S } |: l, x( U8 i
" G! C$ A8 j( a8 ~% k
& t* E1 Z# G, k# n. y9 a Dim oDerivedParamTable As DerivedParameterTable0 z. W ?7 T6 M
c+ Z; z( ~6 |0 o4 u
For Each oDerivedParamTable In oDoc.ComponentDefinition.Parameters.DerivedParameterTables
. T7 s0 r9 `* p+ ] G# k9 T, Z5 [
9 O% D" c8 C4 U$ l
- Z( q% f# T! X' b: g) K2 u: G+ ^1 O( z( y
i = i + 17 t; r# a) R+ ^
6 D' P7 F, N' J* u e1 N5 C oSheet.Cells(i, 1).Value = "Derived Parameters - " & oDerivedParamTable.ReferencedDocumentDescriptor.FullDocumentName7 h: R [) i5 n' X! J# _
9 m. |2 K; `. n5 s oSheet.Cells(i, 1).Font.Bold = True
7 S& e3 @5 |- @0 T9 b$ `: P& U7 P8 U
i = i + 1; k( a- U, j9 N" N: [) C4 B. J( s
, r% a1 B" ]8 Z! G. K# @
* h" N) W8 s' u+ m$ d4 [
2 h/ O4 ^: U% H- _- \- f Dim oDerivedParam As DerivedParameter
" \) f; ~8 w9 V2 X y) |3 e( Z4 L( x* L( t2 z) j) z7 Z
For Each oDerivedParam In oDerivedParamTable.DerivedParameters
, `2 h/ {* b" b6 X/ \6 r- y& @& W. m6 h
+ q% j. \& U9 h8 w( I7 A; s
* n( Q7 [3 H4 B/ @/ Z/ n oSheet.Cells(i, 1).Value = oDerivedParam.Name/ g' l. i8 f: b/ u% M; q! U
: \' @* `2 w+ E1 H5 ~ P) W
oSheet.Cells(i, 2).Value = oDerivedParam.Units
8 K) x3 z- u6 {4 n8 D r7 y1 ~1 \& T1 |! t
oSheet.Cells(i, 3).Value = oDerivedParam.Expression
3 U) s- a4 }: C w6 Y3 @$ V l1 E6 ~& _" W
oSheet.Cells(i, 4).Value = oDerivedParam.Value
" l! m# F& {, _7 t1 U" ?! a- y0 C/ R2 M- Y" r- z% Q
6 M8 w5 Q @, k5 y& e
5 y) ]% A) ~: M f& Y: K i = i + 1$ H F# U. O% v, _: P
( w% }! _, a: o2 d/ I4 ` Next
3 L+ \" M- F, K2 {5 P/ o
1 {$ X! F4 }* E/ } Next7 H) W! r- v) q7 {; z! t/ M$ L' L
8 X1 s* [% n# S5 c
End Sub# s/ z4 p( K! x+ X4 N
( E1 Y! x, d& N" K4 I* X) H B ' E) D' ]4 a. t# E. F
% m3 h* F- f `. Z# Y
, ]4 Q l0 j8 D0 L5 r" a
- C3 J4 J5 q; q1 t1 @4 I第二个方法--- iLogic方法 , 感谢xiaodong Liang
6 y6 }2 o* L W& Y' w8 O- ~
( j! G. o4 f0 K
h; A% W/ ~. c i; v
# g2 f5 i6 s" R6 Q用法,新建一个test.xlsx在C盘下面,然后复制下面内容到一个规则里面。运行即可。1 N9 a7 T" X% `' I
& F$ p4 a* p# b* G% M
Z" U0 p, C0 R5 |7 i
5 g) H( u4 O1 o6 h1 `9 b0 Z8 ?+ O& Z
2 b9 D0 Z% M, ^
6 s3 {) _' h2 j9 [1 q 'Open Excel
. W) \& r& L' X( m GoExcel.Open("c:test.xlsx", "Sheet1")
* O5 L/ ~# q" U a3 B
$ @3 e' x/ g' e, S2 D7 q 'Title of column
+ a* K3 ^* `% X) J GoExcel.CellValue("c:test.xlsx", "Sheet1", "A1") = "Name"- g2 Q# M6 s8 H5 g. I% B
GoExcel.CellValue("c:test.xlsx", "Sheet1", "B1") = "Units"# m( I- G( c3 [8 B2 e0 u
GoExcel.CellValue("c:test.xlsx", "Sheet1", "C1") = "Equation"# s7 g! ]$ `1 G- w6 S
GoExcel.CellValue("c:test.xlsx", "Sheet1", "D1") = "Value (cm)"1 \( s. h p. Z( ~9 z5 M
2 Z% k7 q' A/ [5 d7 r0 g
'Model Parameters. I& A! t- t7 E3 u3 V) w1 }5 C: A
Dim oCurrentIndex As Long = 3, Z$ C0 n* ], Z$ K
GoExcel.CellValue("c:test.xlsx", "Sheet1", "A" & CStr(oCurrentIndex)) = "Model Parameters"
?3 Z4 K; e$ q% p+ o - f n3 S6 O" X" m# E, U Z* d1 _3 _
Dim index As Long
5 B) q% C& ` y7 v# F } Dim oIndexStr As String
% X; P$ x0 T4 R: T; Z4 ` 6 r# N# ]8 @, D/ e* i
Dim oModelPs
6 f% Z" e( M: T5 A( J oModelPs = ThisApplication.Activedocument.ComponentDefinition.Parameters.ModelParameters
0 ^' f& O( Q# m7 { b" w. b0 b r1 g+ z) W- g+ @
For index = 1 To oModelPs.Count
- _- A0 C* A: |2 t& Y5 ~$ A) Q. H5 Z0 F/ B% _
- \. V3 v% x' l: I8 b1 q0 C8 J+ W! @ oIndexStr = "A" & CStr(oCurrentIndex + index)! ~( T: |+ D9 T& @
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oModelPs(index).Name
4 [5 V3 y' m' `2 x6 |, u
# x) y' u9 F& i- m2 m+ }# c oIndexStr = "B" & CStr(oCurrentIndex + index) 0 e! _* [" }. e
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oModelPs(index).Units; O% _+ e" O$ ~- t9 n1 T9 N
6 Q$ p( s& p: k* U7 d
oIndexStr = "C" & CStr(oCurrentIndex + index)
" K( V' [1 W8 J* s) U. O( o GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oModelPs(index).Expression: V- s/ m- O; G* {% |9 S- h$ S! ?
6 `$ Z& w+ ~9 \" K5 `) ~/ F8 L oIndexStr = "D" & CStr(oCurrentIndex + index)
# `2 ]& l/ i2 \1 z0 P3 q. c8 u GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oModelPs(index).Value
: H) x K+ b4 M& n' ~Next8 O+ b# \% N) Q8 z! G
' H/ D8 R/ o( l7 r7 u( ?
'Reference Parameters
0 j3 a, b2 V/ h9 Q% S0 |oCurrentIndex = oCurrentIndex + oModelPs.Count + 1$ u3 c- m8 K& F# h9 B5 r0 M+ v, Y
GoExcel.CellValue("c:test.xlsx", "Sheet1", "A" & CStr(oCurrentIndex) ) = "Reference Parameters", O1 V% ]& ~8 ~
' J, Q) A* P' W Dim oRefPs7 X2 I" n3 W$ k E0 u, t
oRefPs = ThisApplication.Activedocument.ComponentDefinition.Parameters.ReferenceParameters
1 ?, I7 |0 S+ t7 f 4 o5 `5 ^/ F, b9 k7 n) {
For index = 1 To oRefPs.Count" K9 J$ f4 l2 ^. m. Z: F' I2 t
( B1 I, W0 H6 h oIndexStr = "A" & CStr(oCurrentIndex + index)8 p) g+ V& G, r! I% C" U
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oRefPs(index).Name, N, a8 W( G" v) Y
2 P& }" W: G; G+ l$ p% Z' R- g* o
oIndexStr = "B" & CStr(oCurrentIndex + index) ! _ [* A4 F6 j) y
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oRefPs(index).Units
3 k# U: Q' ], ], R, N1 v 3 w$ P" c( J6 a: q4 E
oIndexStr = "C" & CStr(oCurrentIndex + index) 8 r& n/ j$ o& k, C5 I6 Y
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oRefPs(index).Expression
' C+ z& d' M3 ]( `$ c/ w
# J# D7 J, D* P1 |. p$ ~% k oIndexStr = "D" & CStr(oCurrentIndex + index) ; u9 t# I; F. [
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oRefPs(index).Value$ j8 D& F. ?" v6 c- `/ _
Next9 ^' y0 @1 g& d4 g* d: q
, o/ }9 V/ \' M6 G5 P S1 @
'User Parameters
- q% I2 m1 t6 t7 VoCurrentIndex = oCurrentIndex + oRefPs.Count + 1$ w! _/ O( o" \3 d% f4 N. Q7 o
GoExcel.CellValue("c:test.xlsx", "Sheet1", "A" & CStr(oCurrentIndex) ) = "User Parameters"
0 y' W$ W+ J t5 `! ~% c/ J7 T, c( P
Dim oUserPs
- W# A- T# A: J8 T' B# p: ZoUserPs = ThisApplication.Activedocument.ComponentDefinition.Parameters.UserParameters7 r E5 @) T1 S9 E4 H" Y" {/ ~
( x0 U/ ^" @# W. c3 h
For index = 1 To oUserPs.Count
" g8 l3 ?2 x: d2 |4 N# ]4 n& {% i3 q; Y) ~8 k
oIndexStr = "A" & CStr(oCurrentIndex + index)4 r. p1 d- y$ P) I4 o7 R1 N. R
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oUserPs(index).Name
& k8 L) z5 y- s- l- P8 R4 f+ P ) N* T) t0 P! q1 \" {! T' J9 Z2 b% r! B
oIndexStr = "B" & CStr(oCurrentIndex + index)
@3 u+ \6 W! I% |( f$ r' L L GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oUserPs(index).Units; T- j0 Y4 h N& B( @. C; M
$ P& H2 ]% `: Q! J- S
oIndexStr = "C" & CStr(oCurrentIndex + index)
+ q0 o3 d; O; D# E. r GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oUserPs(index).Expression- T: X% V3 H" T+ h- H8 X% U# w
( h6 o1 w4 m, U& E$ Z2 D oIndexStr = "D" & CStr(oCurrentIndex + index) 5 S6 o/ P. U4 H' a( p& v9 y
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oUserPs(index).Value
( Z2 H% x( ^+ ^) j7 l* M1 c) [Next. G4 K& B. b5 V5 ] U
- {+ `9 W) W! x9 n! i
- b! Q9 d' s1 @) z3 R; L5 E
'ParameterTables0 n, {& U: e( R& c, H, e' n
oCurrentIndex = oCurrentIndex +oUserPs.Count + 1
. r7 ~( U, s8 m$ P0 m* V1 jGoExcel.CellValue("c:test.xlsx", "Sheet1", "A" & CStr(oCurrentIndex) ) = "Parameter Table"
. w8 P' m0 e; t; V @ J* H# K C: n2 w
Dim oPTables
. P! R/ x) g9 _( X& M5 }/ doPTables = ThisApplication.Activedocument.ComponentDefinition.Parameters.ParameterTables! ~6 J" j# ]" [& |
- w. h/ O( }3 c' k4 h
For i = 1 To oPTables.Count " V) y$ _6 E% o' I& D
. o. A6 {9 @0 ] ?. i2 q
Dim oEachPTable. Y2 Y4 \1 k) l: I' X
oEachPTable = oPTables(i)
/ H2 e. J0 B& w, k; r6 W3 q
7 T3 c) G7 v1 D: ~6 \" T Dim oPTableParas
, `8 w$ V. N( t- @2 {% O oPTableParas = oEachPTable.TableParameters
' U1 h( M3 D+ R9 e* b. m
8 `8 j; E3 x! q! ^. k- \ oCurrentIndex = oCurrentIndex + 1" N8 P# X9 h' M) X- g) b
GoExcel.CellValue("c:test.xlsx", "Sheet1", "A" & CStr(oCurrentIndex) ) = "Table Parameters - " & oEachPTable.FileName
6 l9 c+ ~/ N2 I& Y. c% A3 ?! X 5 b" m1 Z; g2 K, @6 n9 [7 w- F" ^
For index = 1 To oPTableParas.Count
2 }& O# x/ i0 t& \ 1 T% B+ g, `( H& @
Dim oEachP7 S) Q; J. |! I# m8 I( _+ E. V4 d9 j
oEachP = oPTableParas(index)
, f# ]) p( l: @9 e6 P ?: D6 K
& I9 S! E% [* ~2 s( E; T) z oIndexStr = "A" & CStr(index + oCurrentIndex)
9 F3 s9 P. c2 C0 a+ r GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachP.Name
- Z% U; S; e* i+ T7 }7 [0 K1 N& h/ J& o 5 X4 B( d" ?& D3 F
oIndexStr = "B" & CStr(index +oCurrentIndex)
" O+ L( _! u8 G$ v& L( i7 E1 a2 A/ e6 c GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachP.Units8 I d( R9 |$ W& @
: t& T4 f( h6 h! j1 Z4 D Z! Q9 t3 y# l
oIndexStr = "C" & CStr(index +oCurrentIndex)
" R3 U/ k. } u$ n GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachP.Expression
; ?" W) m+ B, r" y5 u 4 f6 C, y G4 T( f# l! }2 V
oIndexStr = "D" & CStr(index + oCurrentIndex) ' ]! w8 A& n. j6 A1 k- c& e
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachP.Value
! }1 N) n' ~% R4 E' i" d! a Next
+ [5 o- L6 ?. T" C7 T: y+ T
8 I7 v! S/ D# L" s+ t oCurrentIndex = oCurrentIndex + oPTableParas.Count% n- ~1 ?3 n0 n6 C" e+ x' n( t3 y
( m* |2 v/ G8 Z
Next- L0 v6 e5 s( o( G5 q4 \" a5 Y# V6 y' ~
" m) S5 m5 f d7 a'Derived Parameter Table! ~) \) B3 w1 O9 B8 v& t9 k
oCurrentIndex = oCurrentIndex + 11 w3 t0 X3 {5 u
GoExcel.CellValue("c:test.xlsx", "Sheet1", "A" & CStr(oCurrentIndex) ) = "Derived Parameter Table"
# m& d3 l. I9 I# R 9 c8 o; r1 g1 p! w
Dim oDTables9 J6 f( D0 f# J: p2 j8 g
oDTables = ThisApplication.Activedocument.ComponentDefinition.Parameters.DerivedParameterTables
: N4 Y& D8 g6 m g- B1 C5 q3 e- e% `
For i = 1 To oDTables.Count $ G- O4 _$ C. ~1 }! k6 n8 }, \3 g) F
/ c, A' p% A$ K3 v! b5 i
Dim oEachDTable
1 ]" Q9 h& [" B3 F: q* s oEachDTable = oDTables(i)
f- q/ }$ w) r( V 1 N* h- m( r7 c/ W
Dim oDTableParas3 V, _3 q c% f# h" S, i3 e* u
oDTableParas = oEachDTable.DerivedParameters ) i2 u4 {0 a3 p$ E; X
% s) j5 N+ K: V# U
oCurrentIndex = oCurrentIndex + 1
8 n+ j( a0 N: U! m* H GoExcel.CellValue("c:test.xlsx", "Sheet1", "A" & CStr(oCurrentIndex) ) = "Table Parameters - " & oEachDTable.ReferencedDocumentDescriptor.FullDocumentName$ L. R# M1 N D: w; z9 d
# U5 z7 w/ \# @& }! k6 f# N9 ?% H
For index = 1 To oDTableParas.Count
, c' e2 e0 N4 i0 c( f- B" @: ] * F# O; D6 S, F2 s8 G$ o7 n
Dim oEachDP
. Z9 A5 \8 m( }$ ` d7 ]8 O oEachDP = oDTableParas(index)/ h+ H9 Z6 }4 {/ e+ ^1 d, |
2 O$ _" n1 I4 k: K6 B
oIndexStr = "A" & CStr(index + oCurrentIndex)
: g% J. y: ^& w. A+ k GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachDP.Name
; R1 u* B% a. t" w2 x6 j" p ! c" o. k5 d* s: @; q4 c) h' n
oIndexStr = "B" & CStr(index +oCurrentIndex)
* _2 v8 P/ M- b( B5 w GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachDP.Units
0 |+ m% [8 R% y+ U- _ 8 q! J8 I4 v+ i C5 A
oIndexStr = "C" & CStr(index +oCurrentIndex)
( b7 J1 U2 {" |+ b& J GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachDP.Expression1 a, v# ^; C- C ~
/ C+ K/ s) z1 T, `( [ oIndexStr = "D" & CStr(index + oCurrentIndex) ; {" @( O- f6 ^ u
GoExcel.CellValue("c:test.xlsx", "Sheet1", oIndexStr) = oEachDP.Value
! Z! H& A9 l) p% i( T8 ?' l Next
1 J6 v3 ^* T r( F3 p2 H oCurrentIndex = oCurrentIndex + oDTableParas.Count
/ I1 q% k, T4 C% w J6 \% \
: H- }7 _2 ~4 f0 V/ ?( V7 eNext
1 O+ G" D) [ S0 v9 S # z2 x3 R% m6 |% E; s3 t5 z% y
$ a; q, {. e' _) m5 @- W* m$ Z
4 N/ T7 T% d+ T( _
GoExcel.Save, C7 C5 C5 }8 W& m
GoExcel.Close |