Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel Automation Delete Column Causing Problems
Message
From
08/06/2015 16:40:01
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows Server 2003
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01620683
Message ID:
01620744
Views:
41
>>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?

Good idea, but unfortunately that doesn't help.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform