02-10-2016
10:05 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
02-10-2016
10:05 PM
Hi, you have to run it once, then go to parameters (or do it using another rule) and select an value for the "SIZE" parameter. Then run this rule again.
I have added parameter check so you don't need to care if the parameter is created or not. The parameter "MODEL" is not needed as all the values are now stored in the "oMyValues" object.
Sub Main()
CheckParam("SIZE")
MultiValue.SetList("SIZE", "SIZE-AA", "SIZE-BB", "SIZE-CC")
Dim Row As Integer
Dim oMyValues(9, 5) As Object ' Set the range for values (9 rows, 5 columns)
GoExcel.Open("filename.xls", "Sheet1")
Row = 1
For j = 3 To 5 ' Set the rows for AA... values
GetValues(oMyValues, Row, j)
Row = Row + 1
Next
For j = 8 To 10 ' Set the rows for BB... values
GetValues(oMyValues, Row, j)
Row = Row + 1
Next
For j = 13 To 15 ' Set the rows for CC... values
GetValues(oMyValues, Row, j)
Row = Row + 1
Next
GoExcel.Close
Dim oModel As String
oModel = Parameter("SIZE")
Dim MyArrayList As New ArrayList
For i = 1 To UBound(oMyValues, 1)
If oMyValues(i, 1) = oModel Then
MyArrayList.Add(oMyValues(i, 2))
MyArrayList.Add(oMyValues(i, 3))
MyArrayList.Add(oMyValues(i, 4))
MyArrayList.Add(oMyValues(i, 5))
End If
Next
CheckParam("SIZE_VALUES")
MultiValue.List("SIZE_VALUES") = MyArrayList
End Sub
Private Sub GetValues(oMyValues As Object, Row As Integer, j As Integer)
oMyValues(Row, 1) = GoExcel.CellValue("A" & j)
oMyValues(Row, 2) = GoExcel.CellValue("B" & j)
oMyValues(Row, 3) = GoExcel.CellValue("C" & j)
oMyValues(Row, 4) = GoExcel.CellValue("D" & j)
oMyValues(Row, 5) = GoExcel.CellValue("E" & j)
End Sub
Private Sub CheckParam(oParaName As String)
oParameters = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters
Try
Parameter(oParaName) = Parameter(oParaName)
Catch
oParameter = oParameters.AddByValue(oParaName, "", UnitsTypeEnum.kTextUnits)
End Try
End Sub
Here below is the rule to pick one of the "SIZE" parameter values. Use the number to pick (first/second/...) value from the parameter list.
Try
Parameter("SIZE") = Parameter("SIZE")
Parameter("SIZE") = MultiValue.List("SIZE").Item(1)
Catch
MsgBox("The parameter 'SIZE' doesn't exist")
End Try
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
- - - - - - - - - - - - - - -
Regards,
Mike
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods