Public Sub EliminaPedido(Num As Integer, Hoja1 As Worksheet)
and at the main form:
Private Sub bBaja_Click()
Dim x10 As New Excel.Application
Dim ArchivoDestino As Workbook
Dim R As String
R = "Año " & Year(Now)
Set ArchivoDestino = x10.Workbooks.Open(Ruta & "\Registro pedidos.xlsx", 0)
Dim M As Integer
M = MsgBox("Desea eliminar el pedido " & Me.Range("H2").Value & " emitido a " & Me.Range("E11").Value & "?", vbExclamation + vbYesNo, "Pedidos de Elementos")
If M = 6 Then EliminaPedido Me.Range("H2").Value, ArchivoDestino.Worksheets(R)
ArchivoDestino.Close True
End Sub
When EliminaPedido
ends, the object Hoja1
is freed, or into that sub I must use set Hoja1 = Nothing
?