Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Difference when debugging and exe
Message
 
To
10/07/2014 21:48:08
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows 8
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01603500
Message ID:
01603505
Views:
64
Check http://www.foxite.com/archives/0000153776.htm


>The VFP IMPORT command doesn't accept spreadsheets in XLSX format. I developed a routine which converts
>to a more compliant format and imports that. This has worked just fine in XP and Windows 7. When working
>with a Windows 8 machine the code doesn't seem to work at all. It seems as if it exits the function and gives
>all sorts of error messages because the table it is expecting doesn't exist
>FUNCTION xls_import
>PARAMETERS tcFile
>
>** Replaces VFP Import Command for XLS.  VFP Command does not accept new file formats for Excel 
>** Changes for Window 7
>** IMPORT of a bad spreadsheet causes a crash rather than an error
>** Always open and save as old xls version
>
>LOCAL lcReturn,lcNewFile
>lcReturn = ""
>
>	tmpoxl=CREATEOBJECT("excel.application")
>	tmpoxl.DisplayAlerts = .F.
>
>	tmpoxl.Application.WorkBooks.Open(tcFile)
>
>	lcNewFile = "c:\tempdl\" + SYS(3)
>
>	tmpoxl.activeworkbook.saveas(lcnewfile,39)
>	tmpoxl.quit
>	tmpoxl= .null.
>
>	TRY
>		IMPORT FROM (lcnewfile) xls
>		lcReturn = DBF()
>	CATCH
>	ENDTRY
>
>	DELETE FILE (lcnewfile + ".xls")
>
>RETURN lcReturn
>When running in an APP file this routine worked fine in XP and Windows 7. On Windows 8 it didn't work at all.
>
>But the curious part is that when I go into VFP 8 and run this routine in DEBUG mode everything runs fine.
>
>I modified the program somewhat to show error messages
>LOCAL lcReturn,lcNewFile
>lcReturn = ""
>
>        MESSAGEBOX("create XL object")
>	tmpoxl=CREATEOBJECT("excel.application")
>
>        MESSAGEBOX("Set DisplayAlerts")
>	tmpoxl.DisplayAlerts = .F.
>
>        MESSAGEBOX("Open the file")
>	tmpoxl.Application.WorkBooks.Open(tcFile)
>
>	lcNewFile = "c:\tempdl\" + SYS(3)
>
>        MESSAGEBOX("Save the new file")
>	tmpoxl.activeworkbook.saveas(lcnewfile,39)
>
>        MESSAGEBOX("close XL and set object reference to NULL")
>	tmpoxl.quit
>	tmpoxl= .null.
>
>	TRY
>                MESSAGEBOX("Inside TRY, IMPORT statement")
>		IMPORT FROM (lcnewfile) xls
>		lcReturn = DBF()
>	CATCH TO loError
>                MESSAGEBOX("Inside Catch with Error " + TRANS(loError.errorno))
>	ENDTRY
>
>	DELETE FILE (lcnewfile + ".xls")
>
>RETURN lcReturn
>
>When this was compiled into the APP file the program worked just fine.
>
>I don't have access to the workstation till morning. I'll kill all the messageboxes (except the one in the CATCH block)
>and see if there it sill works.
>
>Any ideas why it doesn't work in the APP file but does work in DEBUG mode, or in the APP file with messageboxes?
>
>Thanks for any insights.............Rich
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform