'How to insert an Input Box with non constant number of strings to enter based on selected shapes
I would like to have an InputBox that allows to enter text in a table, for a number of cells taht depends on a previous selection of shapes, however I do not know how to setup the array, could someone show me how?
EDIT:
I added the below loop with array but I get Wrong number of arguments error
Sub InputBox()
Dim iRow As Integer
Dim iColumn As Integer
Dim MasterTitle As Shape
Dim oShapeNavigator As Shape
Dim oSlide As Slide
Dim oSlides As slides
Set oSlides = ActivePresentation.slides
Set MasterTitle = ActivePresentation.SlideMaster.Shapes.Placeholders(1)
Dim Shapesarray() As Shape
Dim TextTable As String
Dim nCounter As Long
ReDim Shapesarray(1 To ActiveWindow.Selection.ShapeRange.Count)
Dim V As Long
For V = 1 To ActiveWindow.Selection.ShapeRange.Count - 1
Set Shapesarray(V) = ActiveWindow.Selection.ShapeRange(V)
Next V
Dim p As Integer
p = 1
ReDim TextArray(1 To V)
Do While p <= V
TextArray(p) = InputBox(Prompt:="Enter Text for cell N." & p)
TextTable = TextArray(p)
Debug.Print TextTable
p = p + 1
Loop
For Each oSlide In oSlides ' ActivePresentation.Slides
If oSlide.CustomLayout.Name = "Section Header" Then
nCounter = nCounter + 1
ElseIf nCounter < V Or nCounter = V Then
Set oShapeNavigator = oSlide.Shapes.AddTable(1, V * 2, Left:=10, Top:=10, Width:=MasterTitle.Width * 11 / 12, Height:=2)
With oShapeNavigator.Table '@@ TABLE @@
For iRow = 1 To .Rows.Count
For iColumn = 2 To .Columns.Count Step 2
For p = 1 To TextTable.Count
With .Cell(iRow, iColumn).Shape.TextFrame.TextRange
.Text = TextTable
End With
Next
Next iColumn
Next iRow
End With
End If
Next oSlide
End Sub
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
