Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to automate Excel cell value update
Message
De
12/09/2005 15:57:54
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01048875
Message ID:
01048932
Vues:
25
Edgar,
This is your code with very slight modifications and it works for me:
lcFile = Sys(5)+Curdir()+"Absorb_2005new.xls"

oExcel=Createobject("Excel.Application")
With oExcel
  .DisplayAlerts= .F.
  .WorkBooks.Open(m.lcFile,0)
  .Sheets("Buffing").Select()
  Do PopulateExcelArray
  .ActiveWorkbook.Close(.T.)
  .Quit
Endwith

Procedure PopulateExcelArray
  Do ProvideDesc

Procedure ProvideDesc
  Do UpdateSpreadsheet

Procedure UpdateSpreadsheet
  sRowId = "5"
  sC = 75
  sH = 80
  sK = 90
  sT = 100
  sAB = 120
  sAd = 140
  sAe = 150
  With oExcel.ActiveWorkbook.WorkSheets("Buffing")
    If !Empty(sa)
      cCell="A"+sRowId
      .Range(cCell).Select()
      .Range(cCell).Value= Date(1990,01,01)&& CTOD(sA)
    Endif
    * The s-CELL Values are all numeric at this point
    If sC > 0
      cCell="C"+sRowId
      .Range(cCell).Select()
      .Range(cCell).Value= sC
    Endif
    If sH> 0
      cCell="H"+sRowId
      .Range(cCell).Select()
      .Range(cCell).Value= sH
    Endif
    If sK> 0
      cCell="K"+sRowId
      .Range(cCell).Select()
      .Range(cCell).Value= sK
    Endif
    If sT> 0
      cCell="T"+sRowId
      .Range(cCell).Select()
      .Range(cCell).Value= sT
    Endif
    If sAB> 0
      cCell="AB"+sRowId
      .Range(cCell).Select()
      .Range(cCell).Value= sAB
    Endif
    If sAd> 0
      cCell="AD"+sRowId
      .Range(cCell).Select()
      .Range(cCell).Value= sAd
    Endif
    If sAe> 0
      cCell="AE"+sRowId
      .Range(cCell).Select()
      .Range(cCell).Value= sAe
    Endif
  Endwith
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform