Methode 'Cells' of object '_Worksheet' failed

  • Thread starter Thread starter Filips Benoit
  • Start date Start date
F

Filips Benoit

Dear All,

Creating an invoice in excel from Access.adp with SQL-server-data.
I have about 10 simular functions to create invoices for other clients,
never had this problem!

There are 2 types of orders in 1 invoice.
First i count the orders for each type.
Then i open excel-template-invoice and write date for each type if present.

Set xlApp = CreateObject("Excel.Application")
Set WB = xlApp.Workbooks.Open(strPath & "\" & strFile)
Set WS = WB.Sheets(1)
xlApp.Visible = True

The 2 parts of code for each ordertype are nearly the same.
If there only are orders of type 1 there are no problems, the invoice is
correctly created and saved.

BUT, the code for type2 triggers error -2147221080 Methode 'Cells' of
'_Worksheet' failed.

This is the codeline that trigger the error
MsgBox iRow ' shows a correctly the rowNr before the error
WS.Cells(iRow, 1).Value = "Tokyo"

After a hole day of looking, testing, stress i'm totally stuck!

Please HELP!

Filip
 
Hi Filips,
This is the codeline that trigger the error
MsgBox iRow ' shows a correctly the rowNr before the error
WS.Cells(iRow, 1).Value = "Tokyo"

After a hole day of looking, testing, stress i'm totally stuck!

Are you sure Sheets(1) is a worksheet and not some other sheet, like a
chart or a dialogsheet?

Or maybe Sheets(1) is protected?

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top