Andreas Hermle
asked on
Inputbox to prompt the user to enter a slide number
Dear Experts:
below macro...
... retrieves several pieces of information from a table on the first slide,
... puts this alltogether into a text box
... which in turn is placed on the bottom of the slides starting from page 2.
I now would like to get this macro tweaked as follows:
The table from which the information is retrieved could be on page 2 or 3 or even on subsequent page.
I therefore would like to get the macro tweaked on line 18 and 26 of the current code:
An inputbox (only numeric integer values are allowed, no greater than the overall number of slides minus 1) is to prompt the user to specify the page number of the table from which to take the data (line 18)
Line 26 should then be adjusted accordingly.
Help is much appreciated. Thank you very much in advance.
below macro...
... retrieves several pieces of information from a table on the first slide,
... puts this alltogether into a text box
... which in turn is placed on the bottom of the slides starting from page 2.
I now would like to get this macro tweaked as follows:
The table from which the information is retrieved could be on page 2 or 3 or even on subsequent page.
I therefore would like to get the macro tweaked on line 18 and 26 of the current code:
An inputbox (only numeric integer values are allowed, no greater than the overall number of slides minus 1) is to prompt the user to specify the page number of the table from which to take the data (line 18)
Line 26 should then be adjusted accordingly.
Help is much appreciated. Thank you very much in advance.
Sub IPS()
Dim pre As Presentation
Dim shp As Shape
Dim strText As String
Dim i As Long
Dim tbl As Variant
Dim shp1 As Variant
Dim tb As Variant
Set pre = ActivePresentation
If MsgBox("Would you like to insert the metadata into the footer of the current presentation?", vbQuestion + vbYesNo, "Add Footer") = vbNo Then
Exit Sub
End If
With pre
For Each shp In .Slides(1).Shapes
If shp.Type = msoTable Then Set tbl = shp.Table
Next
With tbl
strText = .Cell(2, 2).Shape.TextFrame.TextRange.Text & ", " & _
.Cell(9, 2).Shape.TextFrame.TextRange.Text & ", " & _
.Cell(12, 2).Shape.TextFrame.TextRange.Text
End With
For i = 2 To .Slides.Count
For Each shp1 In pre.Slides(i).Shapes
If shp1.AlternativeText = "TableText" Then shp1.Delete
Next
Set tb = pre.Slides(i).Shapes.AddTextbox(msoTextOrientationHorizontal, 30, 566, 750, 40) 'Left, Top, Width, Height
tb.TextFrame.TextRange.Text = strText
tb.AlternativeText = "TableText"
tb.TextFrame2.TextRange.Font.Name = "Calibri Light"
tb.TextFrame2.TextRange.Font.Size = 13
Next i
End With
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi JSR, found out myself how to cope with this error message ... will post the respective code tomorrow ...
Hopefully you converted the string to a Long
Do
Do
lngIndex = InputBox("Enter slide number with table")
Loop While Not IsNumeric(lngIndex)
i = CLng(lngIndex)
Loop While i > pre.Slides.Count - 1 Or i = 0
''''''''''''''''''''''''
With pre
For Each shp In .Slides(i).Shapes
End Sub
Do
Do
lngIndex = InputBox("Enter slide number with table")
Loop While Not IsNumeric(lngIndex)
i = CLng(lngIndex)
Loop While i > pre.Slides.Count - 1 Or i = 0
''''''''''''''''''''''''
With pre
For Each shp In .Slides(i).Shapes
End Sub
ASKER
uppps, sorry, inadvertently pressed the wrong button.
ASKER
There is something wrong with this website. I cannot award points, I just do not see the respective buttons for it.
ASKER
Has JSR been awarded the 1000 points? I got no idea.
ASKER
thank you very much for your swift help.
I am afraid to tell you that your code throws an error message on line 26. I got no idea why because your code looks perfect to me.
The error message is as follows and comes up regardless of which slide number I enter into the input box. Very Strange ...
Help is very much appreciated. Thank you very much in advance. Regards, Andreas