I am porting my version of http://www.j-walk.com/ss/excel/tips/tip53.htm%5B/url%5D to Word.
Got it running, using an array for the definition table. Not totally happy as, besides having 7 arguments,
I have to update the indices by hand with each addition/change of my add-in
Therefore I am toying with putting the information in a table of my add-in. Ran into 2 problems:
1) There does not seem to be a sensible way to avoid the control characters
2) Can not figure out how to retrieve/convert table cell content into numbers
This is how far I got regarding assigning the table values to an array
Sub PutWordTableInto2DimArray() 'Attempt to store strings _and_ numbers in an add-in table 'Basis 'http://mypage.bluewin.ch/reprobst/WordFAQ/Tabellen.htm#Tabellen20 'is in german, seems to be a rather good site Dim arrPar() As Variant Dim oParTable As Table, oParRow As Row, oParCell As Cell Dim iR As Integer, iC As Integer Dim strTxt As String If ActiveDocument.Tables.Count = 0 Then MsgBox "Definition table is missing !", vbInformation Exit Sub End If Set oParTable = ThisDocument.Tables(1) With oParTable ReDim arrPar(1 To .Rows.Count, 1 To .Columns.Count) For Each oParRow In .Rows iR = iR + 1 iC = 0 'Reset For Each oParCell In oParRow.Cells iC = iC + 1 'IS THERE ANY OTHER WAY TO REMOVE/AVOID THE CONTROL CHARS ? 'IF POSSIBLE I'D LIKE TO RETRIEVE NUMBERS (INTEGERS) TOO strTxt = oParCell.Range.Text arrPar(iR, iC) = Left(strTxt, Len(strTxt) - 2) MsgBox arrPar(iR, iC) & ", type=" & VarType(arrPar(iR, iC)) Next oParCell Next oParRow End With End Sub
Work-around: Is there is a better way / tool to program a long _and_ deep (up to 3 levels) menu for an add-in in Word ?