MaximoAccess

Caro Usuário, antes de postar pela primeira vez, leia as regras do fórum.

Obrigado

Administração do MaximoAccess

Dicas Ms Access, Exemplos Ms Access, Codigos VBA Ms Access, SQL Ms Access

    ERRO 1004 Tempo de execucao - erro de definicao de aplicativo ou de objeto

    Compartilhe

    gio_1911
    Novato
    Novato

    Respeito às Regras 100%

    Sexo : Masculino
    Localização : Brasil
    Mensagens : 1
    Registrado : 07/06/2017

    ERRO 1004 Tempo de execucao - erro de definicao de aplicativo ou de objeto

    Mensagem  gio_1911 em Qua 07 Jun 2017, 03:26

    Prezados amigos, preciso de uma ajuda! Criei um codigo em VBA para copiar e colar os dados de pedidos de clientes de uma planilha para outra. E cada vez que a macro roda preenche a planilha de historico na linha de baixo.

    Acontece que ele dá erro na linha em negrito, só que se finalizo o depurador e executo a macro novamente ela roda corretamente...

    O erro que acontece é o 1004- Tempo de execucao - erro de definicao de aplicativo ou de definicao de objeto

    Sub Confirmar_Pedido()
    '
    ' Confirmar_Pedido Macro
    '
    ' Atalho do teclado: Ctrl+Shift+C

           
    Dim cont As Long

    cont = Range("AU1").Value

    Sheets("Historico").Select
    ActiveSheet.Range("B3").Select
    ActiveCell.Offset(cont, 3).Select

               
       Sheets("Pedido").Select
       Range("L6:M6").Select
       Selection.Copy
       Sheets("Historico").Select
       Cells(cont, 2).Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Sheets("Pedido").Select
       Range("M4").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       Cells(cont, 4).Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Sheets("Pedido").Select
       Range("L8:M8").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       Cells(cont, 5).Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Sheets("Pedido").Select
       Range("S1").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       Cells(cont, 7).Select
       ActiveSheet.Paste
       Sheets("Pedido").Select
       Range("L10:O10").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       Cells(cont, Cool.Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Sheets("Pedido").Select
       Range("P10").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       Cells(cont, 13).Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Sheets("Pedido").Select
       Range("Q10:S10").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       Cells(cont, 14).Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Sheets("Pedido").Select
       Range("L12:M12").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       Cells(cont, 17).Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Sheets("Pedido").Select
       Range("N12").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       Cells(cont, 19).Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Sheets("Pedido").Select
       Range("R6:S6").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       Cells(cont, 20).Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Sheets("Carretilhas").Select
       Range("D8").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       Cells(cont, 22).Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Columns("T:T").ColumnWidth = 15
       Cells(cont, 23).Select
       Sheets("Carretilhas").Select
       Range("E8").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Application.CutCopyMode = False
       Selection.Style = "Currency"
       Cells(cont, 24).Select
       Sheets("Carretilhas").Select
       Range("D9").Select
       Selection.Copy
       Sheets("Historico").Select
       ActiveSheet.Paste
       Sheets("Carretilhas").Select
       Range("E9").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       Cells(cont, 25).Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Application.CutCopyMode = False
       Selection.Style = "Currency"
       ActiveWindow.ScrollColumn = 2
       ActiveWindow.ScrollColumn = 3
       ActiveWindow.ScrollColumn = 5
       ActiveWindow.ScrollColumn = 6
       Cells(cont, 26).Select
       ActiveCell.FormulaR1C1 = ""
       Sheets("Carretilhas").Select
       Range("D10").Select
       Selection.Copy
       Sheets("Historico").Select
       ActiveSheet.Paste
       Sheets("Carretilhas").Select
       Range("E10").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       Cells(cont, 27).Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Application.CutCopyMode = False
       Selection.Style = "Currency"
       Cells(cont, 28).Select
       Sheets("Carretilhas").Select
       Range("D11").Select
       Selection.Copy
       Sheets("Historico").Select
       ActiveSheet.Paste
       Sheets("Carretilhas").Select
       Range("E11").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       Cells(cont, 29).Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Application.CutCopyMode = False
       Selection.Style = "Currency"
       Cells(cont, 30).Select
       ActiveWindow.ScrollColumn = 8
       ActiveWindow.ScrollColumn = 9
       ActiveWindow.ScrollColumn = 14
       ActiveWindow.ScrollColumn = 15
       ActiveWindow.ScrollColumn = 18
       Sheets("Varas").Select
       Range("D8").Select
       Selection.Copy
       Sheets("Historico").Select
       ActiveSheet.Paste
       Sheets("Varas").Select
       Range("E8").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       Cells(cont, 31).Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Cells(cont, 32).Select
       Sheets("Varas").Select
       Range("D9").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       ActiveSheet.Paste
       Sheets("Varas").Select
       Range("E9").Select
       Application.CutCopyMode = False
       Selection.Copy
       Cells(cont, 33).Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Cells(cont, 31).Select
       Application.CutCopyMode = False
       Selection.Style = "Currency"
       Cells(cont, 33).Select
       Selection.Style = "Currency"
       Columns("AG:AG").EntireColumn.AutoFit
       Columns("AG:AG").ColumnWidth = 12
       Cells(cont, 34).Select
       Sheets("Varas").Select
       Range("D10").Select
       Selection.Copy
       Sheets("Historico").Select
       ActiveSheet.Paste
       Sheets("Varas").Select
       Range("E10").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       Cells(cont, 35).Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Application.CutCopyMode = False
       Selection.Style = "Currency"
       Cells(cont, 36).Select
       Sheets("Varas").Select
       Range("D11").Select
       Selection.Copy
       Sheets("Historico").Select
       ActiveSheet.Paste
       Cells(cont, 37).Select
       Sheets("Varas").Select
       Range("E11").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Cells(cont, 38).Select
       Sheets("Varas").Select
       Range("D12").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       ActiveSheet.Paste
       Cells(cont, 39).Select
       Sheets("Varas").Select
       Range("E12").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       ActiveSheet.Paste
       Application.CutCopyMode = False
       ActiveCell.FormulaR1C1 = ""
       Cells(cont, 39).Select
       Sheets("Varas").Select
       Selection.Copy
       Sheets("Historico").Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Cells(cont, 40).Select
       Sheets("Varas").Select
       Range("D13").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       ActiveSheet.Paste
       Sheets("Varas").Select
       Range("E13").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       Cells(cont, 41).Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Application.CutCopyMode = False
       Selection.Style = "Currency"
       ActiveWindow.ScrollColumn = 20
       ActiveWindow.ScrollColumn = 21
       ActiveWindow.ScrollColumn = 23
       ActiveWindow.ScrollColumn = 24
       ActiveWindow.ScrollColumn = 25
       Sheets("Varas").Select
       Range("D14").Select
       Selection.Copy
       Sheets("Historico").Select
       Cells(cont, 42).Select
       ActiveSheet.Paste
       Cells(cont, 43).Select
       Sheets("Varas").Select
       Range("E14").Select
       Application.CutCopyMode = False
       Selection.Copy
       Sheets("Historico").Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Application.CutCopyMode = False
       Selection.Style = "Currency"
       Cells(cont, 44).Select
       Sheets("Pedido").Select
       Range("S15").Select
       Selection.Copy
       Sheets("Historico").Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Application.CutCopyMode = False
       Selection.Style = "Currency"
       Selection.Style = "Currency"
       Cells(cont, 45).Select
       Sheets("Pedido").Select
       ActiveWindow.SmallScroll Down:=15
       Range("S30").Select
       Selection.Copy
       Sheets("Historico").Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False
       Application.CutCopyMode = False
       Selection.Style = "Currency"
       Sheets("Pedido").Select
       ActiveWindow.SmallScroll Down:=-3
       Range("M17").Select
       Selection.Copy
       Sheets("Historico").Select
       Cells(cont, 46).Select
       Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
           :=False, Transpose:=False



    End Sub
    avatar
    JPaulo
    Moderador
    Moderador

    Respeito às Regras 100%

    Sexo : Masculino
    Localização : Portugal
    Mensagens : 9550
    Registrado : 04/11/2009

    Re: ERRO 1004 Tempo de execucao - erro de definicao de aplicativo ou de objeto

    Mensagem  JPaulo em Qua 07 Jun 2017, 13:57

    Este site é exclusivo para Ms Access.

    Tópico movido para off-topic.


    .................................................................................
    Contribua com o maximoaccess nos links abaixo, ajude a melhorar este que é o seu site na NET.

    [Você precisa estar registrado e conectado para ver este link.]
    [Você precisa estar registrado e conectado para ver este link.]

    Sucesso e Bons Estudos
    Success and Good Studies

    [Você precisa estar registrado e conectado para ver esta imagem.] [Você precisa estar registrado e conectado para ver este link.]
    [Você precisa estar registrado e conectado para ver esta imagem.] [Você precisa estar registrado e conectado para ver este link.]
    [Você precisa estar registrado e conectado para ver esta imagem.] [Você precisa estar registrado e conectado para ver este link.]

      Data/hora atual: Seg 25 Set 2017, 00:02