Saltar al contenido

al cerrar libros quedan ventanas vacias abiertas


Recommended Posts

hola  he creado un a aplicacion y en uno de los modulos abre y cierra otro libro de excel dependiendo los cambios que se le hagan  guarda y  cierra pero al terminar de usar la aplicacion quedan muchas ventanas vacias abiertas tantas como capturas o modificaciones que hice

 

 

 

este es mi codigo


Private Sub MultiPage2_Click(ByVal Index As Long)
If MultiPage2.Value = 0 Then
Application.Visible = False
Application.ScreenUpdating = False
Workbooks.Open Filename:=ThisWorkbook.Path & "\" & "server.xlsx"
Worksheets("MATERIALES").Activate
Worksheets("MATERIALES").AutoFilter.Sort.SortFields.Clear
Worksheets("MATERIALES").AutoFilter.Sort.SortFields.Add Key:= _
        Range("A1:A1000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
        :=xlSortTextAsNumbers
    With Worksheets("MATERIALES").AutoFilter.Sort
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
 
 Range("a1").Select
Set rngsource = Worksheets("MATERIALES").Range("a2:d1000")
With ListBox1
.List = rngsource.Cells.Value
End With
Windows("server.xlsx").Activate

ActiveWindow.Close savechanges:=False


Else
If MultiPage2.Value = 2 Then
Application.Visible = False
Application.ScreenUpdating = False
Workbooks.Open Filename:=ThisWorkbook.Path & "\" & "server.xlsx"
Worksheets("MATERIALES").Activate
Worksheets("MATERIALES").AutoFilter.Sort.SortFields.Clear
Worksheets("MATERIALES").AutoFilter.Sort.SortFields.Add Key:= _
        Range("A1:A1000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
        :=xlSortTextAsNumbers
    With Worksheets("MATERIALES").AutoFilter.Sort
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
 
 Range("a1").Select
Set rngsource = Worksheets("MATERIALES").Range("a2:d1000")
With ListBox2
.List = rngsource.Cells.Value
End With
Windows("server.xlsx").Activate

ActiveWindow.Close savechanges:=False

End If

End If

Application.Visible = False
Application.ScreenUpdating = True

End Sub

 

 

image.thumb.png.73205eb01c55751dcf0677d5fcab78bf.png

Enlace a comentario
Compartir con otras webs

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

×
×
  • Crear nuevo...

Información importante

Echa un vistazo a nuestra política de cookies para ayudarte a tener una mejor experiencia de navegación. Puedes ajustar aquí la configuración. Pulsa el botón Aceptar, si estás de acuerdo.