Button to open same PDF file with changing index number?

This button will open the first PDF found in a folder which you specify within the button:

After adding the button, edit it to change the line specifying the folder you want it to look in.

The script inside the button looks like this:

Option Explicit
Function OnClick(ByRef clickData)
	Dim cmd, folderEnum, folderItem, folderPath

	folderPath = "C:\Folder Path\With\A PDF In It"

	Set cmd = clickData.func.command
	cmd.deselect = false
	cmd.ClearFiles

	Set folderEnum = DOpus.FSUtil.ReadDir(folderPath, False)
	Do While (Not folderEnum.complete)
		Set folderItem = folderEnum.Next
		If (UCase(folderItem.ext) = ".PDF") Then
			cmd.RunCommand folderItem.RealPath
			Exit Do
		End If
	Loop
End Function