+ Reply to Thread
Results 1 to 2 of 2

Error 1004 Paste method of Worksheet class failed

  1. #1
    Registered User
    Join Date
    05-04-2006
    Posts
    3

    Error 1004 Paste method of Worksheet class failed

    I have a VB COM+ component which exports data from db to a spreadsheet.
    The workbook has around 6 sheets which the VB program fills as part of the export process. It's a huge code with multiple function calls. I have given code snippets in brief.

    Set xlBook = CreateObject("Excel.Application")
    xlBook.Workbooks.Open (File_Path)
    xlBook.DisplayAlerts = False
    ....

    Set xlsheet = xlBook.Workbooks(1).Worksheets("SheetA")
    xlsheet.Activate
    xlsheet.Range(strrangearr(0)).Resize(reccount, UBound(recarray, 1) + 1).Value = TransposeDim(recarray)
    .....
    .....
    Set xlsheet = xlBook.Workbooks(1).Worksheets("SheetB")
    xlsheet.Activate
    xlsheet.Range("PD_attendee_type1").Activate
    xlsheet.Range("PD_attendee_type1").EntireRow.Copy
    xlsheet.Range("PD_attendee_type1").Offset(intCntr1 - 1, 0).EntireRow.Insert
    xlsheet.Paste xlsheet.Range("PD_AT").Offset(intCntr1 - 1, 0).EntireRow, False

    These are 2 ways in which data is copied into the sheets.

    I am unable to debug the COM+ component and also the error occurs irregularly. Any suggestions what could go wrong.

    Thanks in advance.

  2. #2
    Gary''s Student
    Guest

    RE: Error 1004 Paste method of Worksheet class failed

    Only a guess. Sometimes paste fails in VBA if something between the copy and
    the paste empties the clipboard. Try re-aranging the code so the insert does
    not come between the copy and paste.
    --
    Gary's Student


    "skvabbili" wrote:

    >
    > I have a VB COM+ component which exports data from db to a spreadsheet.
    > The workbook has around 6 sheets which the VB program fills as part of
    > the export process. It's a huge code with multiple function calls. I
    > have given code snippets in brief.
    >
    > Set xlBook = CreateObject("Excel.Application")
    > xlBook.Workbooks.Open (File_Path)
    > xlBook.DisplayAlerts = False
    > ....
    >
    > Set xlsheet = xlBook.Workbooks(1).Worksheets("SheetA")
    > xlsheet.Activate
    > xlsheet.Range(strrangearr(0)).Resize(reccount, UBound(recarray, 1) +
    > 1).Value = TransposeDim(recarray)
    > .....
    > .....
    > Set xlsheet = xlBook.Workbooks(1).Worksheets("SheetB")
    > xlsheet.Activate
    > xlsheet.Range("PD_attendee_type1").Activate
    > xlsheet.Range("PD_attendee_type1").EntireRow.Copy
    > xlsheet.Range("PD_attendee_type1").Offset(intCntr1 - 1,
    > 0).EntireRow.Insert
    > xlsheet.Paste xlsheet.Range("PD_AT").Offset(intCntr1 - 1, 0).EntireRow,
    > False
    >
    > These are 2 ways in which data is copied into the sheets.
    >
    > I am unable to debug the COM+ component and also the error occurs
    > irregularly. Any suggestions what could go wrong.
    >
    > Thanks in advance.
    >
    >
    > --
    > skvabbili
    > ------------------------------------------------------------------------
    > skvabbili's Profile: http://www.excelforum.com/member.php...o&userid=34135
    > View this thread: http://www.excelforum.com/showthread...hreadid=539055
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1