ALGUEM PODE ME AJUDAR

USUARIO.EXCLUIDOS 08/06/2005 09:37:11
#87612
Estou fazendo cópias do banco de dados para o excel até aí tudo bem. Na hora que vou fechar o Excel da um erro interno. Estou enviando meu codigo se alguém puder me ajudar. Agradeço desde já.
=========================================================================
Dim Plan5 As Object 'Aplicação Excel
'INSTANCIA OBJETO EXCEL NA MEMÓ“RIA
'**********************************************************************
Set Plan5 = CreateObject("excel.application")

'CHAMA EXCEL / IMPRIME
'**********************************************************************
Plan5.Workbooks.Open App.Path & "\Planilha\Aniversario.xls"
Plan5.Visible = False
Plan5.UserControl = False

'PREENCHE CéLULAS DESEJADAS
'**********************************************************************
With Plan5

sql = "Select * from AniversarioFunc"
Set myrs = Banco.OpenRecordset(sql, dbOpenSnapshot)
If Not myrs.EOF Then
myrs.MoveLast
myrs.MoveFirst
End If

.Cells(1, 3).Value = Format(Date, "dd/mm/yy")

x = 4
Do Until myrs.EOF

.Cells(x, 1).Value = Format(myrs!Data, "dd/mm")
.Cells(x, 2).Value = myrs!Pref
.Cells(x, 3).Value = myrs!Agencia
.Cells(x, 4).Value = myrs!Funcionario
.Cells(x, 5).Value = UCase(myrs!Funcao)

x = x + 1
myrs.MoveNext
Loop

End With

MsgBox "Cópia feita com sucesso.", vbInformation

Plan5.Visible = True

'FECHA REFERÃÅ NCIA AOS OBJETOS
'**********************************************************************
Set Plan5 = Nothing

Exit Sub
End Sub
=========================================================================
USUARIO.EXCLUIDOS 08/06/2005 09:47:07
#87615
Resposta escolhida
Tente
Plan5.Quit
Set Plan5 = Nothing

Se não resolver, poste os detalhes do erro, em que linha acontece, e qual a mensagem de erro...
Tópico encerrado , respostas não são mais permitidas