Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel Automation
Message
De
09/09/2000 12:08:34
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
08/09/2000 17:05:43
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00413062
Message ID:
00414600
Vues:
16
>This saves the entire workbook with the "Grade Sheet" as the active sheet. I just need that one sheet saved to another spreadsheet. I do not want the other sheets saved to the new spreadsheet.


Right Pam,
I think it's a 'feature' of Excel :) However IMHO it's still the way to go not copy(). Copy() could finish its job if you're lucky and Sheet is not crowded. Even if it could succeed it would be much slower than SaveAs (I'd bet a Copy() would take many minutes to complete if sheet has plenty of cells filled).
FUNCTION _ExcelSaveSheeet
LPARAMETERS tcOriginal, tcSaveAs, tcSheet
oExcel = CREATEOBJECT('excel.application')
oExcel.WorkBooks.Open(tcOriginal)
oExcel.ActiveWorkbook.WorkSheets(tcSheet).SaveAs(tcSaveAs)
WITH oExcel.ActiveWorkbook
  .Application.DisplayAlerts = .F.
  FOR each oSheet in .WorkSheets
    IF oSheet.Name # tcSheet
      oSheet.Delete
    ENDIF
  ENDFOR
  .Application.DisplayAlerts = .T.
  .Save
ENDWITH
oExcel.Quit()
But wait there is a faster one (VFP is faster than Excel right ?)
FUNCTION _ExcelSaveSheeet
LPARAMETERS tcOriginal, tcSaveAs, tcSheet
COPY file (tcOriginal) to (tcSaveAs)
oExcel = CREATEOBJECT('excel.application')
oExcel.WorkBooks.Open(tcSaveAs)
WITH oExcel.ActiveWorkbook
  .Worksheets(tcSheet).Activate
  .Application.DisplayAlerts = .F.
  FOR each oSheet in .Worksheets
    IF oSheet.Name # tcSheet
      oSheet.Delete
    ENDIF
  ENDFOR
  .Application.DisplayAlerts = .T.
  .Save
ENDWITH
oExcel.Quit()
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