Muito boa noite,
Estou com um problema numa macro que fiz.
Ao aplicar a macro, o objectivo é o excel guardar a folha do ficheiro em formato .xls. Mas quando o vou abrir esse novo .xls aparece este aviso.
Como corrijo isto? ( em anexo)
Aqui está a macro.
Muito Muito Obrigado
Sub Loop_Through_List()
Dim cell As Excel.Range
Dim rgDV As Excel.Range
Dim DV_Cell As Excel.Range
Set DV_Cell = Range("Z2")
Set rgDV = Application.Range(Mid$(DV_Cell.Validation.Formula1, 2))
For Each cell In rgDV.Cells
DV_Cell.Value = cell.Value
Call PDFActiveSheet
Next
End Sub
Sub PDFActiveSheet()
Dim myFile As Variant
Dim strFile As String
Dim sfolder As String
On Error GoTo errHandler
sfolder = GetFolder()
exitHandler:
Exit Sub
errHandler:
MsgBox "Could not create PDF file"
Resume exitHandler
End Sub
Function GetFolder()
Dim sfolder As Object, NomePasta
Set sfolder = CreateObject("Scripting.FileSystemObject")
NomePasta = "C:\Users\DC\Desktop\Nova pasta (2)" & "\" & "Encomenda"
If Not sfolder.FolderExists(NomePasta) Then
sfolder.CreateFolder (NomePasta)
End If
Sheets("Encomenda").Copy
With ActiveSheet.UsedRange
.Value = .Value
End With
Set wbNew = ActiveWorkbook
wbNew.SaveAs "C:\Users\DC\Desktop\Nova pasta (2)" & "\" & "Encomenda" & "\" & Range("Z2") & ".xlsx"
wbNew.Close True
Application.DisplayAlerts = True
End Function