Link to home
Start Free TrialLog in
Avatar of johnnyg123
johnnyg123Flag for United States of America

asked on

Ignore error checking in vba

I have an access 2003 application that is copying data from a recordset to an excel application opend in the background using the following

 Dim appExcel As Excel.Application
   Dim wbk As Excel.Workbook
   Dim wks As Excel.Worksheet

All seems to be working well except some of the data is resulting in excel displaying the little green triangle indicating a data format error.

I was trying to set a property that would prevent this from happening but can't seem to get the correct format.

Below is the code that loops through the addition of the fields to the excel spreadsheet
The  wks.Cells(iRow, iCol).Errors.Item(xlNumberAsText).Ignore = True is resulting in an object not set error

 For iCol = cStartColumn To cStartColumn + (rst.Fields.Count - 1)
         wks.Cells(iRow, iCol) = rst.Fields(iFld)
                       
         wks.Cells(iRow, iCol).WrapText = True
         wks.Cells(iRow, iCol).Errors.Item(xlNumberAsText).Ignore = True
         wks.Rows(iRow).VerticalAlignment = xlTop
         iFld = iFld + 1
      Next

any ideas?
ASKER CERTIFIED SOLUTION
Avatar of omgang
omgang
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of johnnyg123

ASKER

Not sure what I did different but the following does work

 'Possible values of xlErrorChecks
        'xlEvaluateToError = 1
        'xlTextDate = 2
        'xlNumberAsText = 3
        'xlOmittedCells = 5
        'xlUnlockedFormulaCells = 6
        'xlEmptyCellReferences = 7
         
         wks.Cells(iRow, iCol).Errors.Item(xlEvaluateToError).Ignore = True
         wks.Cells(iRow, iCol).Errors.Item(xlTextDate).Ignore = True
         wks.Cells(iRow, iCol).Errors.Item(xlNumberAsText).Ignore = True
         wks.Cells(iRow, iCol).Errors.Item(xlOmittedCells).Ignore = True
         wks.Cells(iRow, iCol).Errors.Item(xlUnlockedFormulaCells).Ignore = True
         wks.Cells(iRow, iCol).Errors.Item(xlEmptyCellReferences).Ignore = True