Using Excel objects from VB.

Status
Not open for further replies.

Herman

Well-known member
Joined
Oct 18, 2011
Messages
883
Location
Montreal, QC, CA
Programming Experience
10+
I realize this may not be the best forum for this question, but I couldn't find a VBA forum around here, I figured I would ask anyways.

I am working on a test project with TestComplete that involves manipulating some Excel spreadsheets. The project uses VBScript and some helper object. I have written a new routine that reformats data from an existing spreadsheet and throws it in a new one.

I have two questions I have walked around for some time now. Have a look at the following snippet:

CleanedUpExportedWorksheet = CleanedUpExportedWorksheet & objResult.Cells(nRow, nCol).Value & ";"
objResult.Cells(nRow, nCol).Value = objSheet.Cells(currentRow, currentCol).Value
If nCol = 1 then
    If Not CellRegExp.Test(objResult.Cells(nRow, nCol).Value) then
        objResult.Cells(nRow - 1, nCol).Value = objResult.Cells(nRow - 1, nCol).Value & _
                          " " & objResult.Cells(nRow, nCol).Value
        objResult.Rows(nRow).EntireRow.Delete
    End If
End If


When execution comes to this part of the script, the script breaks at line 5 with an "Unknown runtime error.". I have tried various rewrites of the same line, nothing seems to work somehow. The syntax checker of the IDE reports nothing wrong.

My second question is in regards with the .Text property of cells in Excel. Through VBA, you can access that property which is a string containing the representation of the .Value property (what the user sees). That property does not seem to be available from VBScript (in fact there is no Cell class, operations are done on a Range class object...).

Any help would be appreciated.
 
It's generic VB using Excel objects. I'm sure some of us have use those in one language or another.

I fixed it up btw, consider this issue resolved.
 
Status
Not open for further replies.
Back
Top