Hello good morning The image above shows the version of office you are currently using
Indeed the problem appeared in all the files with code
All the files have practically the same code, some have not been used lately and do not work either.
never try to record simple copy and paste macros
this is the code I use
Sub Salvar()
Dim NombreHoja As String
Dim HojaDestino As Range
Dim NuevaFila As Integer
Dim FilasFactura As Integer
Dim i As Integer
Dim j As Integer
Dim NumFactura As Integer
Dim ruta As String
Dim cliente
Dim Respuesta
NombreHoja = "VENTAS"
FilasFactura = Application.WorksheetFunction.CountA(Range("FACTURA[CÓDIGO]"))
NumFactura = ThisWorkbook.Sheets("PROFORMA").Range("C18").Value
cliente = ThisWorkbook.Sheets("PROFORMA").Range("C15").Value
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If FilasFactura = 0 Or Range("valCliente").Value = " " Then _
MsgBox "Verifique que halla ingresado: cliente, codigo, cantidad y descuento.", vbExclamation, "INDUSTRIA ELECTRICA NEWLINE S.A.S ": Exit Sub
'Propiedad FileDialog
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = Application.DefaultFilePath & " \ "
.Title = "INDUSTRIA ELECTRICA NEWLINE S.A.S - Seleccionar carpeta"
.Show
If .SelectedItems.Count = 0 Then
Else
ruta = .SelectedItems(1)
MsgBox "Guardando en PDF Orden de pedido N°'" & NumFactura & "'. Presione Aceptar para continuar...", _
vbInformation, "INDUSTRIA ELECTRICA NEWLINE S.A.S "
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ruta & "\" & "Pedido " & cliente & NumFactura & ".pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
End If
End With
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
With ThisWorkbook.Sheets(NombreHoja)
For i = 1 To FilasFactura
Set HojaDestino = ThisWorkbook.Sheets(NombreHoja).Range("A1").CurrentRegion
NuevaFila = HojaDestino.Rows.Count + 1
.Cells(NuevaFila, 1).Value = NumFactura
.Cells(NuevaFila, 2).Value = Range("FEC").Value
.Cells(NuevaFila, 3).Value = Range("valCliente").Value
.Cells(NuevaFila, 4).Value = Range("valNit").Value
.Cells(NuevaFila, 14).Value = Range("FPAGO").Value
.Cells(NuevaFila, 13).Value = Range("ciud").Value
For j = 1 To 7
.Cells(NuevaFila, j + 4).Value = ThisWorkbook.Sheets("PROFORMA").Cells(20 + i, 1 + j)
Next j
Next i
End With
MsgBox "Salvado", vbInformation, "INDUSTRIA ELECTRICA NEWLINE S.A.S "
ThisWorkbook.Sheets("TD-Consulta-Factura").PivotTables("TDdetalle").PivotCache.Refresh
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Respuesta = MsgBox("Deseas borrar los datos?", vbYesNo + vbQuestion, "EXCELeINFO")
If Respuesta = vbYes Then
With ThisWorkbook.Sheets("PROFORMA")
.Range("B21:B40").ClearContents
.Range("C21:C40").ClearContents
.Range("C15:E15").ClearContents
End With
Else
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End Sub
Sub ConsultarFactura()
Dim Factura
Dim Imprimir As Integer
Factura = InputBox("Ingresa la orden de pedido a consultar.", "Industria Electrica Newline SAS")
Range("C18").Value = Factura
Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem
On Error GoTo ManejadorErrores
Set pt = ThisWorkbook.Sheets("TD-Consulta-Factura").PivotTables("TDdetalle")
Set pf = pt.PivotFields("N° PEDIDO ")
pf.ClearAllFilters
For Each pi In pf.PivotItems
If pi.Name = Factura Then
pi.Visible = True
Else
pi.Visible = False
End If
Next pi
Imprimir = MsgBox("Deseas imprimir la factura?", vbYesNo + vbQuestion, "Industria Electrica Newline SAS")
If Imprimir = vbYes Then
ActiveSheet.PrintOut Copies:=1
Else
End If
Exit Sub
ManejadorErrores:
MsgBox "La factura " & Factura & " puede que no exista", vbExclamation, "Industria Electrica Newline SAS"
Range("C18").ClearContents
End Sub
This is the only part of the code that I used recording macro to save files in PDF