InDesign PDF Preset problem

After checking previous posts I came up with the script below:

set lPDFName to "Macintosh HD:Users:Rectal Exambot:Desktop:Test File.pdf"
set lPDFPreset to "[press]" -- Pulled from Excel workbook
set lProjectDocument to active document

tell application "InDesign CS"
	set lPresetList to name of PDF export presets -- Get list of valid export presets
	
	if lPresetList contains lPDFPreset then -- If lPDFPreset is a valid preset
		set page range of PDF export preferences to all pages
		tell lProjectDocument
			export format PDF type to lPDFName using lPDFPreset without showing options -- Make PDF in users name
		end tell
		
	else
		activate
		display dialog "The preset chosen does not exist." buttons {"Okay"} giving up after 5
	end if
	
end tell

The three variables at the top of the script (lPDFName, lPDFPreset, lProjectDocument) are more or less accurate, although the lPDFName will actually change every time the script is run and the desktop is used only for illustration purposes. What happens when I run this as is - I get the following error message “InDesign CS got an error: Document “TestDoc.indd” doesn’t understand the export message”. In order for that message to pop up though lPDFPreset MUST have been in the list lPresetList and thus a valid PDF preset.

Now when I change the export line to read

export format PDF type to lPDFName without showing options -- Make PDF in users name

I get the PDF output I wanted BUT it defaults to the last used preset. So now I know that the issue is with the ‘using lPDFPreset’ portion of the script but WHY? If it can be found in the lPresetList then it must be valid right? Without being able to set the preset via AS then this is useless to me, can anybody point me in the right direction?

Thanks in advance.

I managed to fix this but am not 100% sure how I did it. All I THINK I did was change the value for the variable lPDFPreset to “[Press]” instead of “[press]”. So if that was it then it was a simple matter of capitalization. Dumb. :rolleyes: