Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel.Save() or SaveAs() fails with error 1426
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01307589
Message ID:
01307626
Vues:
19
>>Hi All,
>>
>>I have 2 customers out of 1000's who for some reason Excel is failing to save files.
>>
>>I did run a test on one of the sites with this code:
>>
>>Local oExcel, oWorkbook, oWorksheet
>>oExcel = CreateObject("Excel.Application")
>>oWorkbook = oExcel.Workbooks.Add()
>>oWorksheet = oWorkbook.Worksheets(1)
>>oExcel.DisplayAlerts = .F.
>>oExcel.Cells(1, 1).Value = "AAA"
>>oExcel.Cells(1, 2).Value = "BBB"
>>oExcel.Cells(1, 3).Value = "CCC"
>>oExcel.Cells(1, 4).Value = "DDD"
>>
>>oWorkbook.SaveAs("C:\Test.xls") &&- errors here
>>oExcel.Quit()
>>Return
>>
>>
>>Any ideas please?
>>
>>Thank you
>
>Could you check in Task Manager whether instances of other hidden Excel.exe are running? It might be that you did not close them properly on the previous run.
>
>Also, I would modify your code to avoid additional Excel childs objects:
>
>oExcel = CreateObject("Excel.Application")
>with oExcel
>     .DisplayAlerts = .F.
>     .Workbooks.Add()
>     with .ActiveSheet
>         .Cells(1, 1).Value = "AAA"
>         ..........
>     endwith
>     .ActiveWorkbook.SaveAs("C:\Test.xls")
>      .Quit()
>endwith
>oExcel=NULL
>release oExcel
>
Good idea,

Apparently on one of the 2 problem sites (the problem goes away when they re-boot). So this doesn make sense. Thanks.
Mathias Banda

Time is longer than a rope.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform