Olá não funcionou, estou enviando parte do codigo as vezes posso estar fazendo errado, obrigado.
Dim Plan As Object
If rsTabela.EOF = False And rsTabela.BOF = False Then
'Verifica se o arquivo de modelo do Excel existe
If Existe(App.Path & "TextoTabela_de_Produtos.xls") Then
Set Plan = CreateObject("Excel.Application")
Plan.Workbooks.Open App.Path & "TextoTabela_de_Produtos.xls"
Plan.Worksheets("Plan1").Range("a2:IV65000").ClearContents
With Plan
.Range("A1").value = "Autor"
.Range("B1").value = "Título"
.Range("C1").value = "Editora"
.Range("D1").value = "Ano"
.Range("E1").value = "Estante"
.Range("F1").value = "Preço"
.Range("G1").value = "Descrição"
.Range("H1").value = "Peso"
.Range("I1").value = "Meta-prateleira"
i = 2
Do While rsTabela.EOF = False
If rsTabela!PrecoVenda <> "0" And rsTabela!PrecoVenda <> "R$ 0,00" And rsTabela!PrecoVenda <> "0,00" And rsTabela!QuantidadeEstoque > 0 Then
.Cells(i, 1) = rsTabela!Autor
.Cells(i, 2) = rsTabela!DescricaoProduto
.Cells(i, 3) = rsTabela!Editora
.Cells(i, 4) = rsTabela!Ano
.Cells(i, 5) = rsTabela!Assunto
.Cells(i, 6) = rsTabela!PrecoVenda
.Cells(i, 7) = rsTabela!Observacao
.Cells(i, 8) = rsTabela!Peso
.Cells(i, 9) = rsTabela!Setor
.Cells(i, 10) = " "
i = i + 1
contador = contador + 1
End If
If rsTabela!PrecoVendaNovo <> "0" And rsTabela!PrecoVendaNovo <> "R$ 0,00" And rsTabela!PrecoVendaNovo <> "0,00" And rsTabela!QuantidadeEstoqueNovo > 0 Then
.Cells(i, 1) = rsTabela!Autor
.Cells(i, 2) = rsTabela!DescricaoProduto
.Cells(i, 3) = rsTabela!Editora
.Cells(i, 4) = rsTabela!Ano
.Cells(i, 5) = rsTabela!Assunto
.Cells(i, 6) = rsTabela!PrecoVendaNovo
.Cells(i, 7) = rsTabela!Observacao
.Cells(i, 8) = rsTabela!Peso
.Cells(i, 9) = rsTabela!Setor
.Cells(i, 10) = " "
i = i + 1
contador = contador + 1
End If
rsTabela.MoveNext
Loop
End With
Plan.ActiveWorkbook.SaveAs FileName:="C:SGITextoTabela_de_Produtos.xls"
Plan.ActiveWorkbook.Close SaveChanges:=False
Plan.Quit
Set Plan = Nothing
Else
Beep
MsgBox "Arquivo modelo do Excel não foi localizado para que os registros " & vbCrLf & " sejam exportados, contate o administrador do sistema.", vbCritical, "Aviso"
Exit Sub
End If