Private Sub PDFDoc(fullPdfFileNameAndPath As string)

Dim document as object
Dim dispatcher as Object
Dim args(3) as new com.sun.star.beans.PropertyValue

	On Local Error GoTo ErrorHandler
		
	'Disable screen update
	lockScreen(True)	
	
	document = ThisComponent.CurrentController.Frame
	dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
			
	args(0).Name = "URL"
	args(0).Value = fullPdfFileNameAndPath
	args(1).Name = "FilterName"
	args(1).Value = "writer_pdf_Export"
	args(2).Name = "ExportBookmarks"
	args(2).Value = True
	args(3).Name = "UseTaggedPDF"	'Use document headings
	args(3).Value = True

	dispatcher.executeDispatch(document, ".uno:ExportDirectToPDF", "", 0, args())

	'Re-enable screen update
	lockScreen(False)
	Exit Sub

	ErrorHandler:
		dispError("PDFDoc", Err, Error, Erl)
		
End Sub
