Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Copiar un Rango de celdas a PDF

publicado

Hola @Antoni Gusto en saludarte.

En un Post anterior vi esto tuyo que lo pasa a JPG

Sub Export()
 Dim oWs As Worksheet
 Dim oRng As Range
 Dim oChrtO As ChartObject
 Dim lWidth As Long, lHeight As Long
 Set oWs = ActiveSheet
 Set oRng = oWs.Range("B2:H11")
 oRng.CopyPicture xlScreen, xlPicture
 lWidth = oRng.Width
 lHeight = oRng.Height
 Set oChrtO = oWs.ChartObjects.Add(Left:=0, Top:=0, Width:=lWidth, Height:=lHeight)
 oChrtO.Activate
 With oChrtO.Chart
  .Paste
  .Export Filename:="Case.jpg", Filtername:="JPG"
 End With
 oChrtO.Delete
End Sub

Existe la manera de hacer lo mismo pero a PDF?

Gracias.

Featured Replies

publicado

Ese código no es mío, pero contestando a tu consulta te paso unas macro que hacen lo que pides.

Solo tienes que cambiar el rango y el nombre del archivo.

Rango de la hoja activa:

Sub RangoPDF()
   Dim Archivo As String
   Range("A1:C15").CopyPicture xlScreen, xlPicture
   Sheets.Add                          'Hoja de trabajo
   Range("C5").Select                  'Celda de destino
   ActiveSheet.Paste
   '--
   Archivo = ThisWorkbook.Path & "F:\Mi archivo.pdf" 'Archivo a crear
   ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Archivo
   '--
   Application.DisplayAlerts = False   'Ignora mensajes
   ActiveSheet.Delete                  'Eliminamos la hoja de trabajo
   Application.DisplayAlerts = True    'Restaura mensajes
End Sub

Toda la hoja:

Sub HojaPDF()
   Dim Archivo As String
   '--
   Archivo = ThisWorkbook.Path & "F:\Mi archivo.pdf" 'Archivo a crear
   ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Archivo
   '--
End Sub

 

Editado el por Antoni

publicado
  • Autor

Muchisimas gracias... En todoexcel estas como Macro Antonio?

 

publicado
hace 4 minutos , Janlui dijo:

Muchisimas gracias... En todoexcel estas como Macro Antonio?

 

Si.

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.