Wsht.Cells(1, 1).Activate
Wsht.ChartObjects(Wsht.ChartObjects.Count).Delete
Shp.Delete
End Sub
40. Converter todos os arquivos de uma pasta para
Esta rotina automaticamente converte todos os arquivos do tipo Excel em
uma pasta de origem, para PDF em uma pasta destino.
Obs: Substituir os valores de exemplo em negrito pelos valores desejados.
Sub PdfConvert()
Dim iNumArq As Integer
Dim iCounter As Integer
Dim sMyFiles() As String
Dim OriginFolder As String
Dim DestinyFolder As String
OriginFolder = "C:\Pasta_Origem"
DestinyFolder = "C:\Pasta_Destino"
FileFound = FindFiles(OriginFolder, sMyFiles, iNumArq, "*", True)
If FileFound Then
For iCounter = 1 To iNumArq
Filename = sMyFiles(2, iCounter)
ExtCount = Len(Filename) - Application.WorksheetFunction.Search(".",
Filename, 1) + 1
Workbooks.Open (OriginFolder & "\" & Filename)
Workbooks(Filename).Activate
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=
DestinyFolder & "\" & Mid(Filename, 1, Len(Filename) - ExtCount) &
".pdf", Quality:=
xlQualityStandard, IncludeDocProperties:=True,
IgnorePrintAreas:=False, _
OpenAfterPublish:=False