VBA Powerpoint: add list number in a column table

Hello Experts,
I have the following procedure that I use in my personal.xlsb in order to quickly add list number in an specific column:
Sub Add_List_Number()
Dim strCol As String
Dim lngLastRow As Long
Dim lngRow As Long
Dim intPos As Integer
Dim strPrefix As String

strCol = InputBox("Please enter the column letter in which you add specific row number", "Choose Column Letter")
lngLastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row


    For lngRow = 1 To lngLastRow
    Cells(lngRow, strCol).Value = lngRow
    Next
End Sub

Open in new window


I would like to take it as a reference to add list number in a column table in power point. Every time when a set up table in power point I use list number and when I add additional row I need to retype list number manually. I would like to add this procedure in my powerpoint add in in order to avoid to perform this task manually.

Thank you again for your feedback.
LVL 1
LD16Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

abbas abdullaCommented:
Hi,
In PowerPoint there  are limited options for vba event codes. Check the below code it will insert serial number to a PowerPoint  table in 1st column. make sure to select the table before running.

Sub TableSerialnumbers()

    Dim Shp As Shape
    Dim oTbl As Table
    Dim RowsCount As Long
    Dim ColumnsCount As Long
 

'Select the table before running the code, code will place serial number to the 1'st column

    Set Shp = ActiveWindow.Selection.ShapeRange(1)
    With Shp
If .HasTable Then
            Set oTbl = Shp.Table
            With oTbl
                'Debug.Print .Rows.Count
                'Debug.Print .Columns.Count

                For ColumnsCount = 2 To .Rows.Count

                    With .Cell(ColumnsCount, 1)
                    .Shape.TextFrame.TextRange.Text = ColumnsCount - 1
                    End With
                    Next
                End With
End If
            End With
End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LD16Author Commented:
Hello,
It works! Thank you very much for your help.
I take the opportunity to ask you your advice concerning the best add-in in powerpoints that can help me to be more productive in powerpoint in terms of formatting, alignement, shortcuts etc..
abbas abdullaCommented:
Honestly I never tried using addins ever in ms office apps my preference is always vba.
I recommend you this site for PowerPoint vba: http://www.pptfaq.com/FAQ00033_How_do_I_use_VBA_code_in_PowerPoint.htm

And for addons I found this article useful after googling "powerpoint add ins"

https://www.ispringsolutions.com/blog/boost-your-powerpoint-7-free-powerpoint-add-ins/
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

LD16Author Commented:
Noted, thank you. Last question: if you don't use add in how do you call recurrent procedures in PPT vba as in PPT there is not available the personal.xlsb as excel?
abbas abdullaCommented:
I normally store the codes in same file, but for your case you can create master file as Macro enabled format .pptm and then keep this file opened to call procedures from whenever you need them.
LD16Author Commented:
Noted. Thank you for those advices.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.