How i export pdf using macro

how i export pdf file (without prompt) using macro and how i same pdf file is same openoffice file name.

General advice: If you think to need “macros”, read the guide and study the famous texts by Andrew Pitonyak availabele from his site.
Concerning the specific case: Use the document method storeToURL with the appropriate export filter writer_pdf_Export.
Very specific: The export to pdf supports lots of settings via the FilterData property. For most or all of them you can accept the defaults most likely. However, I don’t know exactly which ones of these defaults in fact are the values chosen the last time export to pdf was done. Thus I give the short version here, and attach an example document containing the macro with the huge set of FilterData settings the recorder passes to the .uno:Save... command.

Both the versions contain the composition of the .pdf url from the url of the Writer document replacing its original extension. You may decide to better simply append the .pdf.

===Edit1 2019-01-10 17:43 CET===
Considering the comments below I slightly reworked the posted code. The replacing attachment (both Sub) is reworked in the same way. Old OOo Basic did not accept the rededication of a missing Optional parameter to a variable taking its place. Recent LibreOffice and also Apache Openoffice V 4.1.5 I tested with both accepted that shorthand way.

Code provided as is without any guarantee!

Sub simpleWriterExportToPdf_ToDocumentFolder(Optional pDoc As Object)
REM Reworked to also run in very old versions.
If IsMissing(pDoc) Then 
  theDoc           = ThisComponent
Else
  theDoc           = pDoc
End If
docUrl             = theDoc.URL
If NOT FileExists(docUrl) Then
  MsgBox("The document must be saved to an URL for this routine to work.")
  Exit Sub
End If
If NOT theDoc.supportsService("com.sun.star.text.TextDocument") Then
  MsgBox("This routine can only export Writer documents.")
  Exit Sub
End If
docURLsplit        = Split(docURL, ".")
docExt             = docURLsplit(Ubound(docURLsplit))
pdfURL             = Left(docURL, Len(docURL) - Len(docExt) -1) & ".pdf"
Dim storeArgs(0) As New com.sun.star.beans.PropertyValue
storeArgs(0).Name  = "FilterName"
storeArgs(0).Value = "writer_pdf_Export"
theDoc.storeToURL(pdfUrl, storeArgs())
End Sub

The announced attachment.

thanks for your help.
but is not functioning correctly, i am using openoffice 2.0
i think is not support.

Sory! Sorry! Sorry! I uploaded the demo before I had pasted the “macro” in. Next miute this will be rectified.
However, OOo V 2.0 is very old.( I can’t test with it). The oldest version I can test with is OOo V 3.2.
I did. There is a problem that also would break the above originally posted code. Obviously such old versions do not accept the name of a missing Optional parameter in place of a variable. Please, always post the message if you get reported an error. To get compatible with such very old versions I changed the code a bit.

supper is functioning correctly, thank you very much.

Glad this helped you.
The askbot (the sofware used by this site) provides the feature “mark this answer as correct” for the case. It is linked to the checkmark left of the first few lines of the answer.
Highlighting accepted answers should help other users searching for suitable answers to similar questions.