Scripting export from InDesign to PDF

I am trying to export each page of an Indesign CS file to individual PDF’s. This is what I have so far, any help would be greatly appreciated.

Thanks,
Tom

repeat with i from 1 to count of document 1
	set myPage to i as string
	set MyPDF to "Desktop:Test" & myPage & ".pdf" --create valid path
	 
	tell application "InDesign CS"
		set page range of PDF export preferences to page i
		tell document 1
			export format PDF type to MyPDF using "[Press]" without showing options
		end tell
	end tell
end repeat

This works for me:

tell application "InDesign CS"
    
    -- This section gets the info from the document 
    set myDocument to active document
    set myName to name of myDocument
    set myPages to pages of myDocument
    
    set myFolderPath to (choose folder with prompt "Please select the folder you want to save your PDF pages in") as string
    set myStyles to name of PDF export presets
    set myExportStyle to (choose from list myStyles with prompt "Please Choose an Export style") as string
    
    -- This part is used to get a special character in the file name 
    set mySeparator to "_"
    
    --This is where things actuaclly are happening 
    repeat with anItem in myPages
        set myPageNumber to name of anItem as string
        set MyPDF to myFolderPath & myName & mySeparator & myPageNumber & ".pdf"
        set page range of PDF export preferences to myPageNumber
        tell myDocument
            export format PDF type to MyPDF using myExportStyle without showing options
        end tell
    end repeat
end tell

Kari

Thanks you, it worked perfectly!

This was a great bit of help - tried to get PDF export to work in one of my scripts - nothing. Then I found this - thanks a bunch.