Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel Automation Delete Column Causing Problems
Message
 
 
À
05/06/2015 20:02:38
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows Server 2003
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01620683
Message ID:
01620684
Vues:
59
>I have two very similar Excel automation methods. One is 100% reliable. The other one almost always works the first time it's run, but fails with an OLE error on a subsequent run: OLE error code 0x80004005: Unspecified error. The code of the problem method is:
>
>* Open the FOX2X DBF in Excel, save to .XLSX format:
>m.loExcel.DisplayAlerts = .F.
>m.loWorkbook = m.loExcel.Workbooks.Open( m.lcDBF2X )
>m.loWorkbook.SaveAs( m.lcFileName )
>
>* Update column headers with previously saved values:
>m.loWorkSheet = m.loWorkbook.WorkSheets( 1 )
>m.lnSelect = SELECT( 0 )
>m.lnIx = 1
>
>SELECT _XLHeaders
>SCAN ALL
>	m.loWorkSheet.Cells( 1, m.lnIx ).NumberFormat = "@"
>	m.loWorkSheet.Cells( 1, m.lnIx ).Value = ALLTRIM( _XLHeaders.Hdr )
>	
>	m.lnIx = m.lnIx + 1
>
>ENDSCAN
>
>* BZ5952 - 2015.04.13 - Al Doman
>* Post-processing 2: remove unneeded Referral PK column:
>m.loWorkSheet.Columns( 3 ).Delete( )
>
>m.loWorkbook.Save( )
>
>* Cleanup:
>m.loExcel.Quit( )
>m.loExcel = .NULL.
>RELEASE m.loExcel
>
If I comment out the .Delete( ) call, this method is also 100% reliable. Also, if I get the OLE error and click on Ignore, the spreadsheet is created normally except that Column3 is not deleted. So, even though the error message doesn't say which command is causing the problem, that's more evidence it's the .Delete( ) call.
>
>Anyone have any ideas why that call could be causing problems, and how to mitigate?

Did you try save, then delete, then save again?
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform