RE:Excel a pdf con visual basic
Que yo sepa no,
Pero es muy facil con los programas gratuitos que hay para convertir a PDF que te crean una impresora y lo único que tienes que hacer es imprimirlos por esa impresora,
Que paso el código que yo uso con en programa PDFCreator.
No es mio, lo saqué de algún foro y ahora no recuerdo de donde,
Public Sub ejecutar()
Set pdfjob = New PDFCreator.clsPDFCreator
With pdfjob
If .cStart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator.", vbCritical + _
vbOKOnly, "PrtPDFCreator"
Exit Sub
End If
End With
PrintToPDF_Early
RestoreDefaults
pdfjob.cCloseRunningSession
pdfjob.cClose
Set pdfjob = Nothing
Application.ScreenUpdating = True
Enviar
End Sub
Public Sub PrintToPDF_Early()
'Author : Ken Puls (www.excelguru.ca)
'Macro Purpose: Print to PDF file using PDFCreator
' (Download from http://sourceforge.net/projects/pdfcreator/)
' Designed for early bind, set reference to PDFCreator
Dim sPDFName As String
Dim sPDFPath As String
'/// Change the output file name here! ///
sPDFName = "Nombre del Fichero a crear"
sPDFPath = "Directorio donde crearlo"
'Check if worksheet is empty and exit if so
If IsEmpty(ActiveSheet.UsedRange) Then Exit Sub
With pdfjob
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sPDFPath
.cOption("AutosaveFilename") = sPDFName
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cClearCache
End With
'Print the document to PDF
ActiveSheet.PrintOut copies:=1, ActivePrinter:="PDFCreator"
'Wait until the print job has entered the print queue
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
pdfjob.cPrinterStop = False
'Wait until the PDF file shows up then release the objects
Do Until Dir(sPDFPath & sPDFName) <> ""
Debug.Print sPDFPath & sPDFName
DoEvents
Loop
End Sub
Sub RestoreDefaults()
'Author : Ken Puls (www.excelguru.ca)
'Macro Purpose: Reset the PDFCreator seetings to their default values
'Dim objPDF As New PDFCreator.clsPDFCreator
With pdfjob
If .cStart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator.", vbCritical + _
vbOKOnly, "PrtPDFCreator"
Exit Sub
End If
'Set Values
.cOption("UseAutosave") = 0
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = "\"
.cOption("AutosaveFilename") = ""
.cOption("AutosaveFormat") = 0
.cOption("UseCreationdate") = vbNullString
.cOption("UseStandardAuthor") = 0
.cOption("PDFUseSecurity") = 0
.cOption("PDFUserPass") = 0
.cOption("PDFUserPassString") = vbNullString
.cOption("PDFOwnerPass") = 1
.cOption("PDFOwnerPassString") = vbNullString
.cOption("PDFEncryptor") = 0
.cOption("PDFDisallowCopy") = 1
.cOption("PDFDisallowPrinting") = 0
.cOption("PDFDisallowModifyContents") = 0
.cOption("PDFDisallowModifyAnnotations") = 0
.cOption("PrinterTempPath") = "El directorio por defecto de la aplicación"
'Save Values
.cSaveOptions
End With
'Set objPDF = Nothing
End Sub