Jump to content
  • Revista PROGRAMAR: Já está disponível a edição #60 da revista programar. Faz já o download aqui!

vpess

Problema ao Exportar para Excel

Recommended Posts

vpess

Boa noite,

Estou com um pequeno problema ao exportar uns dados para excel. Acontece que a primeira vez que exporto não dá problemas, se voltar a carregar no botao para exportar dá-me a seguinte mensagem:

errodm.jpg

O código:

Private Sub Command8_Click()
conexao
procura = Trim(CStr(servico.Text))

    Dim oApp As Excel.Application
    Dim oWB As Excel.Workbook
    
    'Create an Excel instalce.
    Set oApp = New Excel.Application
    'Open the desired workbook
    Set oWB = oApp.Workbooks.Open(FileName:="C:\teste\baixameo.xls")
    'Do any modifications to the workbook.
    SQL = "select * from ot where servico='" + procura + "' ORDER BY servico asc"
    rs.Open SQL, conn, 1, 3

    oApp.Application.Visible = True

    a = "A"
    b = "B"
    c = "C"
    d = "D"
    Range(b & 9).FormulaR1C1 = "NÃO"
    
    oWB.Application.Quit
    Set oWB = Nothing
    oApp.Application.Quit
    Set oApp = Nothing
    
End Sub

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.