Christopher Greaves |
|||
Christopher Greaves |
|||
If you are interested in applications please visit www.VBASolutions.ca .
If you are interested in end-user macros please visit www.TorontoMacros.com .
We continue our exploration of VBA code by writing a small procedure that will allow us to visit each named List Template in a List Gallery.
Public Function lngLocateNamedListTemplate(lstG As ListGallery, Optional lngStart) As LonglngLocateNamedListTemplate = -1 ' default result is failure
Dim lngStartingPoint As Long
If IsMissing(lngStart) Then
lngStartingPoint = 1
Else
lngStartingPoint = CLng(lngStart)
End If
Dim lng As Long
For lng = lngStartingPoint To lstG.ListTemplates.Count
If Len(lstG.ListTemplates(lng).Name) = 0 Then ' not named
Else
lngLocateNamedListTemplate = lng
Exit For
End If
Next lng
End Function
Sub TESTlngLocateNamedListTemplate()
Debug.Print lngLocateNamedListTemplate(Application.ListGalleries(wdOutlineNumberGallery))
End Sub
Sub TESTlngLocateNamedListTemplate()Debug.Print lngLocateNamedListTemplate(Application.ListGalleries(wdOutlineNumberGallery))
Debug.Print lngLocateNamedListTemplate(Application.ListGalleries(wdOutlineNumberGallery), 4)
End Sub
I used the results of my first test to prime the starting point for the second test)
6