Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Uploading an Excel 97 format file in Visual Foxpro 6.0
Message
 
To
15/11/2002 11:32:39
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00721429
Message ID:
00723297
Views:
8
Something like this:

For user to create excel file properly:

lcfile="file_name.xls"

ObjExcel= CREATEOBJECT("Excel.Application")
with ObjExcel
.Workbooks.Open(fullpath(lcfile))
if .Workbooks(1).FileFormat#16 and .Workbooks(1).FileFormat#29
=messagebox("The source file "+lcfile +" is not properly formatted."+chr(13)+chr(10)+;
"It may cause a crash when you attempt to add information from this file."+repl(chr(13)+chr(10),2)+;
"It is highly recommended that you open source file in Excel and "+chr(13)+chr(10)+;
" SAVEAS it as Excel 2.1 or Excel 3.0. "+repl(chr(13)+chr(10),2)+;
"Do not forget to close Excel after that!",64,"Rebate")
endif
.Workbooks.Close
endwith
ObjExcel.quit
ObjExcel=.NULL.

Another solution is to saveAS file with another name:

xlValues = -4163
xlExcel2 = 16

ObjExcel= CREATEOBJECT("Excel.Application")
ObjExcel.DisplayAlerts = .f.
ObjExcel.Workbooks.Open("c:\book1.xls",,,,password_if_any)
ObjExcel.ActiveSheet.UsedRange.Copy
ObjExcel.Workbooks.Add
ObjExcel.Selection.PasteSpecial(xlValues)
ObjExcel.ActiveWorkbook.SaveAs("C:\Book2.xls",xlExcel2)
ObjExcel.Quit
release objexcel


>The problem is this excel 97 fiel is to be imported - from within the application - Is it possible for Fox to call Excel and do some cleanup (Edit - Select All - Copy - Paste Special - Values) or alternatively invoke Excel from within the app - open the file and save in a lower version of Excel and return back to the application and upload the modified file. I mean - the user need not open excel and save the Excel sheet in a lower version - explicitly. There is an issue exporting to Excel 97 with VFP 6.0 - It is really surprising such problems have not come to light. I would be glad if u could help.
>
>Extract of my message to Sergey
>
>Quote
>"
>Sergey,
>
>When i even try to upload this Excel file from the command prompt in VFP6.0 using the command
>
>append from filename.xls type xls
>
>Fox responds with the message - Fatal error - Exception code C0000005
>
>Also, when i use the .exe runs the error message is
>Fatal Error - Exception code C0000005
>Called from - form1.command1.click Line 10 {g:\almexe\upload.sct}
>Called from - main line 12 {g:\almexe\main.prg}
>
>Code associated with form1.command1.click
>** asking the user for the input file and storing the name to a global variable
>close tables
>PUBLIC gctable
>gctable = GETFILE('XLS', 'Browse:', 'Browse', 0, 'Browse')
>THISFORM.text1.VALUE = gctable
>**Calling the validation process to determine the field lengths
>use combmail
>zap
>append from '&gctable' type xls
>dele all for day = 0
>pack
>close tables
>**If the user decides to conitnue enabling the upload option
>THISFORM.command2.ENABLED=.T.
>THISFORM.command2.SETFOCUS
>
>P.S. - I can send u the screen dumps if u can give me your e-mail id. Basically, the issue here is that VFP 6.0 - append from command does not import the Excel 97 file format. Even copy to filename.xls type xls - does not export the output of the table to Excel 97.
>
>" Unquote
Previous
Reply
Map
View

Click here to load this message in the networking platform