Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Moving Worksheets from one book to another
Message
De
30/07/2008 04:52:04
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01335195
Message ID:
01335196
Vues:
17
>I have used the following code from "Microsoft Office Automation with Visual Foxpro" by Tamar Granor but I can't it to work
>
>
>loTempWorkBook = CREATEOBJECT("Excel.Application")
>loTempWorkBook.Workbooks.Open("C:\Dev\Questback\Data\Invicta\Repairs(REP)\"+DTOS(DATE()-1)+"RSLSummary.xls")
>loTempWorkBook.Visible = .T.
>loMTWorkBook = CREATEOBJECT("Excel.Application")
>loMTWorkBook.Workbooks.Open("C:\Dev\Questback\Data\Invicta\Repairs(REP)\"+DTOS(DATE()-1)+"RepairURL.xls")
>loMTWorkBook.Visible = .T.
>
>loTempWorkBook.Worksheets(1).Move(loMTWorkBook.ActiveSheet)    && Error on this line
>
>loMTWorkBook.SaveAs = ("C:\Dev\Questback\Data\Invicta\Repairs(REP)\"+DTOS(DATE()-1)+"RepairURL.xls")
>RELEASE loTempWorkBook
>
>
>
>Error Message:
>
>OLE IDespatch exception code 0 from Microsoft Office Excel:
>Unable to get the move property of the Worksheet class
>
>Is there something missing in the move syntax? Can any one help? Is there another way to do this?

Tony,
That doesn't look like correct syntax to me for a move operation and I believe the problem lies in the fact that you are creating 2 excel sessions.

Would you try this:
LOCAL loX,loTempWorkBook,loMTWorkBook, lcXLS1,lcXLS2
lcXLS1 = "C:\Dev\Questback\Data\Invicta\Repairs(REP)\"+DTOS(DATE()-1)+"RSLSummary.xls"
lcXLS2 = "C:\Dev\Questback\Data\Invicta\Repairs(REP)\"+DTOS(DATE()-1)+"RepairURL.xls"

loX = CREATEOBJECT("Excel.Application")
loTempWorkBook = loX.Workbooks.Open(m.lcXLS1)
loMTWorkBook   = loX.Workbooks.Open(m.lcXLS2)
loX.Visible = .T.
loTempWorkBook.Worksheets(1).Move(loMTWorkBook.ActiveSheet)
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