WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Excel
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Finding Data in Excel Cells

Keywords:   Finding Data Excel Cells

Question:

I made the following routine which imports data from a textfile into a blank worksheet in Excel which works fine. Now I want to know which cell in the (A1:A1000) range containes "VEE" (forelast line of the routine) but that produces an error 3250: Ole Object: Problem ocuured when formatting parameters, any idea what is wrong ?


handle         = FileOpen("f:\clienten\clienten.txt","READ")
DB             = ObjectOpen("Excel.Application")
DB.Visible     = @TRUE
DB.UserControl = @TRUE

oAPP = DB.Workbooks
oAPP.Open("f:\clienten\clienten.xls")
oACT = DB.ActiveWorkbook
oWKS = DB.Worksheets
oWS  = DB.Worksheets(4)
oWS.Activate

line = ""
counter = 1
While line <> "*EOF*"
  line = FileRead(handle)
  if line == "*EOF*" then break
  delim1      = StrIndex(line,";",1,@FWDSCAN)
  delim2      = StrIndex(line,";",delim1+1,@FWDSCAN)
  delim3      = StrIndex(line,";",delim2+1,@FWDSCAN)
  oCell       = oWS.Range("A%counter%")
  oCell.Value = StrSub(line,1,delim1-1)
  oCell       = oWS.Range("B%counter%")
  oCell.Value = StrSub(line,delim1+1,delim2-delim1-1)
  oCell       = oWS.Range("C%counter%")
  oCell.Value = StrSub(line,delim2+1,delim3-delim2-1)
  oCell       = oWS.Range("D%counter%")
  oCell.Value = StrSub(line,delim3+1,-1)
  counter     = counter + 1
Endwhile
adress = oWS.Range("A1:A1000").Find("VEE", lookin:=xlValues)
Message("Find adress", adress)

Answer:


adress = oWS.Range("A1:A1000").Find("VEE", lookin:=xlValues)
is too complicated for WinBatch and you need to specify the xl Constants. See Article ID: W14691 for predefined Excel constants and change your code to:

xlValues = -4163
DaRange = oWS.Range("A1:A1000")
AdrCode = DaRange.Find("XYZ" :: lookin=xlValues)
if AdrCode == 0
  CellAdr = "Not Found"
else
  CellAdr = AdrCode.Address
endif
Message("Found cell address", CellAdr)

Article ID:   W14695
Filename:   Finding Data in Excel Cells.txt
File Created: 2002:04:01:12:35:42
Last Updated: 2002:04:01:12:35:42