Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Copying from one worksheet to another with VFP
Message
De
20/05/2003 09:50:02
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
20/05/2003 08:13:31
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00790369
Message ID:
00790423
Vues:
19
>Hi All,
>
>I have 2 excel files and I need to copy some of the contents from the first to the second using code in my VFP application.
>
>For some reason when I run it I receive error messages such as "Invalid Index" or "Call was rejected by the callee".
>
>Could any one help?
>
>The code I used was:
>
>oexcel = CREATEOBJECT("Excel.Application")
>
>thefile = FULLPATH('file1.xls')
>oexcel.workbooks.OPEN(thefile)
>
>thefile = ALLT('file2.xls')
>oexcel.workbooks.OPEN(thefile)
>
>oexcel.worksheets("file1").RANGE("A1:B100").COPY(oexcel.worksheets("file2").RANGE("B1:C100"))
>
>Here I got stuck. It simply refused to do the job with all kind of (the above-mentioned) excuses.
>
>Thanks in advance,
>
>Jonathan
lcXLS1 = sys(5)+curdir()+"file1.xls"
lcXLS2 = sys(5)+curdir()+"file2.xls"

LOCAL loExcel
loExcel = CreateObject("Excel.Application")
with loExcel
 .Workbooks.Open(lcXLS1)
 .Workbooks.Open(lcXLS2)
 .Workbooks(justfname(lcXLS1)).WorkSheets(1).Range('a1:b100).Copy( ;
   .Workbooks(justfname(lcXLS2)).WorkSheets(1).Range('B1'))
 .Visible = .T.
ENDWITH
PS:IOW file1 and file2.xls would be workbook names.
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
Répondre
Fil
Voir

Click here to load this message in the networking platform