Button to open same PDF file with changing index number?


I would like to create a button which opens a PDF file with changing index numbers. For example, the file name is TEST_01.PDF and changes to TEST_xx.PDF from time to time. Obviously a normal link won't work here.

Is there a way to open such a "variable" file?

It's the only PDF file in the folder, BTW.


If it's always the only PDF in that folder, a command like

Select *.pdf

should do the job. Thera are also select command to select the most recent files, so you could combine things.

Edit: i couldn't find an Opus command to open the file. So you need to push "Enter".

Do you want to open the pdf file from a particular folder, or do you want a button which finds the pdf file below the current directory and opens that?

Hey Leo, the PDF is in a particular (always the same) folder!

Thanks abr, I'm pretty sure there is an Opus command to open files in that manner ... in my experience there is a command for everything, haha :grinning:

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

	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
End Function

Thanks a lot Leo!

The script works like a charm and does exactly what I wanted. Thumbs up!


1 Like