Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy error in access 97 database

Status
Not open for further replies.

vba317

Programmer
Mar 5, 2009
708
US
I am running an access 97 database and I keep on getting an error: The formula or sheet you want to copy contains the name 'CFY' which already exists on the destination worksheet.
The error occurs two more times with two other names. The part of the program that the problem occurs in is copying a template into another spreadsheet. I originally thought it was the templates that might be causing this so I went into the individual templates and I saw that names defined in the templates had a #Ref error in them so I deleted the name definitions. The error is still occurring at the code that is in blue.I am still getting the error so I was hoping I could get some assistance.

Tom

Code:
 ' *** Copy Report to Print Workbook
                    strWorkbook = "\\salmfilesvr1\public\client services\automate\Rpts\" & (mstrUCI) & "\" & (strCurTmp)
                    If (rstRpts![typ] <> "DBL") Then
                        With goXL
                            .Workbooks.Open FileName:=strWorkbook
                            .ActiveWorkbook.ConflictResolution = xlLocalSessionChanges
                            .Sheets(strSheet).Select
                            .Sheets(strSheet).Name = strNewSheet
                            With .Sheets(strNewSheet)
                                .Select
                                .Range("A1:AZ2500").Copy
                                .Range("A1:AZ2500").Select
                                .Range("A1:AZ2500").PasteSpecial Paste:=xlValues
                                .Cells(1, 1).Select
             [Blue]             .Copy After:=Workbooks("Print1").Worksheets(3)  [/Blue]
                            End With
                            ' *** Close workbook hoolding original reports
                            .Workbooks("" & (strCurTmp) & "").Close SaveChanges:=False
                        End With

                    End If
 
Code:
With goXL
    With .Workbooks.Open(Filename:=strWorkbook)
        .ConflictResolution = xlLocalSessionChanges
        .Sheets(strSheet).Name = strNewSheet
        With .Sheets(strNewSheet)
            With .Range("A1:AZ2500")
                .Copy
                .PasteSpecial Paste:=xlPasteValues
            End With
            .Cells(1, 1).Select
            .Copy After:=[highlight]goXL.[/highlight]Workbooks("Print1").Worksheets(3)
        End With
        ' *** Close workbook holding original reports
        .Close SaveChanges:=False
    End With
End With

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top