Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Running Excel from VFP App
Message
De
06/05/2006 10:15:26
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
06/05/2006 09:45:28
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01119766
Message ID:
01119864
Vues:
17
>Thanks a lot for your help, but I allready done it....
>
>This is the final code, I wonder if you say any comments about it....
>
> if !IsClassRegistered("Excel.Application")
> messagebox("Excel is not installed")
> else
> a="C:\estaib\archivos\abril2006.xls"
> b="C:\estaib\archivos\rankingabril2006.xls"
> oExcel = createobject("Excel.application")
> with oExcel
> .Workbooks.Open(a)
> .visible = .t.
> .ActiveWorkBook.ActiveSheet.Range("E:E").Numberformat = "#,##0"
> .ActiveWorkBook.ActiveSheet.Range("F:F").Numberformat = "#,##0.00"
> .ActiveWorkBook.ActiveSheet.Range("A1:F1").Font.Bold=.t.
> .ActiveWorkBook.ActiveSheet.Range("A1:F65536").Font.Size=10
> .ActiveWorkBook.ActiveSheet.Range("A1:F65536").Font.Name='Tahoma'
> .ActiveWorkBook.ActiveSheet.Range("A1:F65536").EntireColumn.AutoFit
> .ActiveWorkBook.ActiveSheet.Range("A1:F1").HorizontalAlignment = -4108
> .ActiveWorkBook.ActiveSheet.Range("A1:F1").VerticalAlignment = -4108
> .ActiveWorkbook.Save
> .Workbooks.Open(b)
> .visible = .t.
> .ActiveWorkBook.ActiveSheet.Range("C:C").Numberformat = "#,##0.00"
> .ActiveWorkBook.ActiveSheet.Range("D:D").Numberformat = "#,##0"
> .ActiveWorkBook.ActiveSheet.Range("A1:F1").Font.Bold=.t.
> .ActiveWorkBook.ActiveSheet.Range("A1:F65536").Font.Size=10
> .ActiveWorkBook.ActiveSheet.Range("A1:F65536").Font.Name='Tahoma'
> .ActiveWorkBook.ActiveSheet.Range("A1:F65536").EntireColumn.AutoFit
> .ActiveWorkBook.ActiveSheet.Range("A1:F1").HorizontalAlignment = -4108
> .ActiveWorkBook.ActiveSheet.Range("A1:F1").VerticalAlignment = -4108
> .ActiveWorkbook.Save
> endwith
> endif

Andrews,
I'ts OK but I suggest you to change your writing style a bit. ie:
If !IsClassRegistered("Excel.Application")
  Messagebox("Excel is not installed")
Else
  a="C:\estaib\archivos\abril2006.xls"
  b="C:\estaib\archivos\rankingabril2006.xls"
  oExcel = Createobject("Excel.application")
  With oExcel
    .Workbooks.Open(m.a)
    .Visible = .T.
    With .ActiveWorkBook.ActiveSheet
      .Range("E:E").Numberformat = "#,##0"
      .Range("F:F").Numberformat = "#,##0.00"
      .Range("A1:F1").Font.Bold=.T.
      With .Range("A:F").Font
        .Size=10
        .Name='Tahoma'
      Endwith
      .Range("A:F").EntireColumn.AutoFit
      .Range("A1:F1").HorizontalAlignment = -4108
      .Range("A1:F1").VerticalAlignment = -4108
    Endwith
    .ActiveWorkbook.Save
    .Workbooks.Open(m.b)
    With .ActiveWorkBook.ActiveSheet
      .Range("C:C").Numberformat = "#,##0.00"
      .Range("D:D").Numberformat = "#,##0"
      .Range("A1:F1").Font.Bold=.T.
      With .Range("A:F").Font
        .Size=10
        .Name='Tahoma'
      Endwith
      .Range("A:F").EntireColumn.AutoFit
      .Range("A1:F1").HorizontalAlignment = -4108
      .Range("A1:F1").VerticalAlignment = -4108
    Endwith
    .ActiveWorkbook.Save
  Endwith
Endif
Besides with..endwith note that I removed numbers where it was A1:F65536 ("A:F" instead to mean columns A:F.)
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