I have an application created in Access 2007 that writes some Excel spreadsheets. The application worked perfectly with Excel 2007 but after switching to Excel 2010 began to display error 1004 in some specific points of the code at the time of writing in Excel. The error is always in a Range method. Here are two code snippets indicating the line where an error occurs to exemplify.
Any tips for this problem, please?
With Excel
.Range(ColInicial & CtlLinha).Select
.Selection.EntireRow.INSERT
.Sheets("Modelo").Select
.Range(RECOParaProjeto!Range5Modelo).Select '<<<<<<<<<<< Error here only with Excel 2010
.Selection.Copy
.ActiveWindow.LargeScroll ToRight:=-1
.Sheets(strDescGuia).Select
.Range(ColInicial & CtlLinha).Select
.Selection.PasteSpecial Paste:=-4122, Operation:=-4142, _
SkipBlanks:=False, Transpose:=False
.Application.CutCopyMode = False
End With
With Excel
.Range(ColInicial & CtlLinha).Select
.Selection.EntireRow.INSERT
.Range(RECOParaProjeto!Item & CtlLinha).Value = strItem
.Range(RECOParaProjeto!Atividade1 & CtlLinha).Value = RECO!N1 '<<<<<<<<<<< Error here only with Excel 2010
.Range(RECOParaProjeto!Atividade2 & CtlLinha).Value = RECO!N2
.Range(RECOParaProjeto!Atividade3 & CtlLinha).Value = RECO!N3
.Range(RECOParaProjeto!Atividade4 & CtlLinha).Value = RECO!N4
.Range(RECOParaProjeto!Atividade5 & CtlLinha).Value = RECOParaProjeto!CN5
.Range(RECOParaProjeto!AtividadeDesc & CtlLinha).Value = RECO!DescAtivP4
.Sheets("Modelo").Select
.Range(RECOParaProjeto!Range4Modelo).Select
.Selection.Copy
.ActiveWindow.LargeScroll ToRight:=-1
.Sheets(strDescGuia).Select
.Range(ColInicial & CtlLinha).Select
.Selection.PasteSpecial Paste:=-4122, Operation:=-4142, _
SkipBlanks:=False, Transpose:=False
.Application.CutCopyMode = False
End With
Any tips for this problem, please?
With Excel
.Range(ColInicial & CtlLinha).Select
.Selection.EntireRow.INSERT
.Sheets("Modelo").Select
.Range(RECOParaProjeto!Range5Modelo).Select '<<<<<<<<<<< Error here only with Excel 2010
.Selection.Copy
.ActiveWindow.LargeScroll ToRight:=-1
.Sheets(strDescGuia).Select
.Range(ColInicial & CtlLinha).Select
.Selection.PasteSpecial Paste:=-4122, Operation:=-4142, _
SkipBlanks:=False, Transpose:=False
.Application.CutCopyMode = False
End With
With Excel
.Range(ColInicial & CtlLinha).Select
.Selection.EntireRow.INSERT
.Range(RECOParaProjeto!Item & CtlLinha).Value = strItem
.Range(RECOParaProjeto!Atividade1 & CtlLinha).Value = RECO!N1 '<<<<<<<<<<< Error here only with Excel 2010
.Range(RECOParaProjeto!Atividade2 & CtlLinha).Value = RECO!N2
.Range(RECOParaProjeto!Atividade3 & CtlLinha).Value = RECO!N3
.Range(RECOParaProjeto!Atividade4 & CtlLinha).Value = RECO!N4
.Range(RECOParaProjeto!Atividade5 & CtlLinha).Value = RECOParaProjeto!CN5
.Range(RECOParaProjeto!AtividadeDesc & CtlLinha).Value = RECO!DescAtivP4
.Sheets("Modelo").Select
.Range(RECOParaProjeto!Range4Modelo).Select
.Selection.Copy
.ActiveWindow.LargeScroll ToRight:=-1
.Sheets(strDescGuia).Select
.Range(ColInicial & CtlLinha).Select
.Selection.PasteSpecial Paste:=-4122, Operation:=-4142, _
SkipBlanks:=False, Transpose:=False
.Application.CutCopyMode = False
End With