VBA Excel - Exporte as planilhas para PDF ou XPS - Export Data to PDF or XPS Using the Excel.ExportAsFixedFormat Method

Inline image 1


Este exemplo mostra como usar o método ExportAsFixedFormat para exportar uma série de dados em uma planilha do Microsoft Excel para o formato PDF ou XPS.

Sub TestExportAsFixedFormat() 
  ' For information on the final parameter, see this page: 
  
  Dim rng As Range 
  Set rng = Range("A1:E10") 
  SetupRangeData rng 
  
  Dim fileName As String 
  ' Change this file name to meet your own needs: 
  Let fileName = "C:\Temp\Export.pdf" 
  
  ' Many of these properties are optional, and are included 
  ' here only to demonstrate how you might use them. The 
  ' Type parameter can be one of xlTypePDF and xlTypeXLS; 
  ' the Quality parameter can be one of xlQualityStandard and 
  ' xlQualityMinimum. Setting the OpenAfterPublish property 
  ' to True will fail if you don't have a default viewer 
  ' installed and configured. 
  
  rng.ExportAsFixedFormat Type:=xlTypePDF, _ 
   fileName:=fileName, Quality:=xlQualityStandard, _ 
   IncludeDocProperties:=True, IgnorePrintAreas:=True, _ 
   From:=1, To:=1, OpenAfterPublish:=True 
End Sub 
Sub SetupRangeData(rng As Range) 
  Let rng.Formula = "=RANDBETWEEN(1, 100)" 
End Sub 



Anexos:



Tags: VBA, Excel, Export, Data, PDF, XPS, ExportAsFixed, Format, Method


Nenhum comentário:

Postar um comentário

diHITT - Notícias