Quitar excel de la memoria.
Publicado por Manuel Pastrana Orozco (44 intervenciones) el 30/08/2005 18:14:05
Saludos a tod@s
Tengo un aplicativo que interacciona con excel bajo el código que se lista, el conflicto se crea ya que excel se queda residente en la memoria y al realizar una segunda corrida genera errores del tipo 91 y 104 al tratar de seleccionar y dar formato a las hojas o celdas, espero puedan ayudarme a encontrar el horror, perdón, error.
Agradezco de antemano su valiosa ayuda.
‘ Exportación a Hoja de Cálculo
' Generando objeto excel
Set oObjExcel = CreateObject("Excel.Application.11") ‘Office 2003
If oObjExcel Is Nothing Then
MsgBox "No se puede crear el reporte", vbExclamation, "Reportes" & AppVersion
Exit Sub
End If
With oObjExcel
.Visible = True
.Workbooks.Add
.Sheets("Hoja1").Select
ActiveWindow.Zoom = 75
.Sheets("Hoja1").Name = "Resumen"
Sheets.Add
.Sheets("Hoja2").Select
.Sheets("Hoja2").Name = "Detalle 1"
ActiveWindow.Zoom = 75
.Sheets("Detalle 1").Move After:=Sheets(2)
…
…
.Sheets.Add
.Sheets("Hoja8").Select
.Sheets("Hoja8").Name = "Detalle 8"
ActiveWindow.Zoom = 75
.Sheets("Detalle 8").Move After:=Sheets(8)
End With
…
…
Ruta = "C:\Composición al " & Format(txt_Fecha.Text, "yyyy mm dd") & ".xls"
Set x1Hoja = Nothing
‘ Guardar, cerrar archivo y eliminar el objeto Excel
With oObjExcel
.ActiveWorkbook.SaveAs FileName:= _
Ruta, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
.ActiveWorkbook.Close
.Application.Quit
End With
Set oObjExcel = Nothing
Tengo un aplicativo que interacciona con excel bajo el código que se lista, el conflicto se crea ya que excel se queda residente en la memoria y al realizar una segunda corrida genera errores del tipo 91 y 104 al tratar de seleccionar y dar formato a las hojas o celdas, espero puedan ayudarme a encontrar el horror, perdón, error.
Agradezco de antemano su valiosa ayuda.
‘ Exportación a Hoja de Cálculo
' Generando objeto excel
Set oObjExcel = CreateObject("Excel.Application.11") ‘Office 2003
If oObjExcel Is Nothing Then
MsgBox "No se puede crear el reporte", vbExclamation, "Reportes" & AppVersion
Exit Sub
End If
With oObjExcel
.Visible = True
.Workbooks.Add
.Sheets("Hoja1").Select
ActiveWindow.Zoom = 75
.Sheets("Hoja1").Name = "Resumen"
Sheets.Add
.Sheets("Hoja2").Select
.Sheets("Hoja2").Name = "Detalle 1"
ActiveWindow.Zoom = 75
.Sheets("Detalle 1").Move After:=Sheets(2)
…
…
.Sheets.Add
.Sheets("Hoja8").Select
.Sheets("Hoja8").Name = "Detalle 8"
ActiveWindow.Zoom = 75
.Sheets("Detalle 8").Move After:=Sheets(8)
End With
…
…
Ruta = "C:\Composición al " & Format(txt_Fecha.Text, "yyyy mm dd") & ".xls"
Set x1Hoja = Nothing
‘ Guardar, cerrar archivo y eliminar el objeto Excel
With oObjExcel
.ActiveWorkbook.SaveAs FileName:= _
Ruta, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
.ActiveWorkbook.Close
.Application.Quit
End With
Set oObjExcel = Nothing
Valora esta pregunta


0