Error on oSheet1:SaveAs(cFILE_NAME)
Moderator: Rathinagiri
- serge_girard
- Posts: 3165
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Error on oSheet1:SaveAs(cFILE_NAME)
Hello,
I create a sheet and when the sheet is shown and the file allready exists I get an error: Error WINOLE/1007 (0x800A03EC): SAVEAS (DOS Error -2147352567) in case I decide NOT the overwrite the sheet.
Is there a way to avoid this error?
Thanks, Serge
I create a sheet and when the sheet is shown and the file allready exists I get an error: Error WINOLE/1007 (0x800A03EC): SAVEAS (DOS Error -2147352567) in case I decide NOT the overwrite the sheet.
Is there a way to avoid this error?
Thanks, Serge
There's nothing you can do that can't be done...
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Error on oSheet1:SaveAs(cFILE_NAME)
Can you check beforehand whether such file exists using
if file( cFile_Name )
else
endif
if file( cFile_Name )
else
endif
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
- serge_girard
- Posts: 3165
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Error on oSheet1:SaveAs(cFILE_NAME)
Thanks Rathi,
But end-users might decide to NOT save and then same error occurs...
Serge
But end-users might decide to NOT save and then same error occurs...
Serge
There's nothing you can do that can't be done...
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Error on oSheet1:SaveAs(cFILE_NAME)
Please send me some sample code. I shall try.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
- serge_girard
- Posts: 3165
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Error on oSheet1:SaveAs(cFILE_NAME)
Rathi,
Take this little sample. Compile and run, then save the XLS.
Then press button again and then click NO to the XLS-question if you want to replace the (new) file.
Then error will occur!
Thanks if you can help.
Serge
Take this little sample. Compile and run, then save the XLS.
Then press button again and then click NO to the XLS-question if you want to replace the (new) file.
Then error will occur!
Thanks if you can help.
Serge
Code: Select all
#include "hmg.ch"
FUNCTION MAIN()
/***************/
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 200 ;
HEIGHT 200;
TITLE ' xls' ;
MAIN
@ 10,10 BUTTON bt_test ;
CAPTION 'XLS' ;
FONT 'Arial' SIZE 8 ;
HEIGHT 86 ;
WIDTH 86 ;
TOOLTIP 'XLS' ;
ACTION Create_XLS()
END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
RETURN
FUNCTION Create_XLS()
/********************/
cFILE_NAME := 'C:\TEST\TEST.XLS'
oExcel1 := CreateObject( "Excel.Application" )
oExcel1:WorkBooks:Add()
oSheet1 := oExcel1:ActiveSheet()
oSheet1:Cells:Font:Name := "Arial"
oSheet1:Cells:Font:Size := 12
oSheet1:Cells( 1, 1 ):Value := "Email address"
oSheet1:Cells( 1, 1 ):Font:Size := 16
oSheet1:Cells( 1, 2 ):Value := "name 1"
oSheet1:Cells( 1, 2 ):Font:Size := 16
oSheet1:Cells( 1, 3 ):Value := "name 2"
oSheet1:Cells( 1, 3 ):Font:Size := 16
aARR := {}
aadd(aARR, {'sg1@sg.be', 'name11','name21'})
aadd(aARR, {'sg2@sg.be', 'name12','name22'})
aadd(aARR, {'sg3@sg.be', 'name13','name23'})
aadd(aARR, {'sg4@sg.be', 'name14','name24'})
aadd(aARR, {'sg5@sg.be', 'name15','name25'})
aadd(aARR, {'sg6@sg.be', 'name16','name26'})
aadd(aARR, {'sg7@sg.be', 'name17','name27'})
aadd(aARR, {'sg8@sg.be', 'name18','name28'})
aadd(aARR, {'sg9@sg.be', 'name19','name29'})
nCEL := 2
FOR i := 1 To LEN (aARR)
oSheet1:Cells( nCEL, 1 ):Value := aARR [ i ] [ 1 ]
oSheet1:Cells( nCEL, 2 ):Value := aARR [ i ] [ 2 ]
oSheet1:Cells( nCEL, 3 ):Value := aARR [ i ] [ 3 ]
oSheet1:Columns( 1 ):AutoFit()
oSheet1:Columns( 2 ):AutoFit()
oSheet1:Columns( 3 ):AutoFit()
nCEL++
NEXT i
oSheet1:Cells( 1, 1 ):Select()
oExcel1:Visible := .T.
oSheet1:SaveAs(cFILE_NAME)
RETURN
There's nothing you can do that can't be done...
Re: Error on oSheet1:SaveAs(cFILE_NAME)
The error only occurs if the file is already open
- Clip2Mania
- Posts: 99
- Joined: Fri Jun 13, 2014 7:16 am
- Location: Belgium
Re: Error on oSheet1:SaveAs(cFILE_NAME)
oExcel:DisplayAlerts := 0 ... ?
- serge_girard
- Posts: 3165
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Error on oSheet1:SaveAs(cFILE_NAME)
I'll try Erik!
Thx, Serge
Thx, Serge
There's nothing you can do that can't be done...
Re: Error on oSheet1:SaveAs(cFILE_NAME)
Hi,
There is a simple solution:
Please try this before saving:
if !IsReadOnly(cXlFileNameWithFullPath)
oSheet1:SaveAs(cXlFileNameWithFullPath)
endif
FUNCTION IsReadOnly(cFile)
LOCAL nOpen := fopen(cFile,FO_EXCLUSIVE)
// if cFile is already open, nOpen will be -1
if nOpen != -1
FClose(nOpen)
endif
RETURN nOpen = -1
HTH,
Warm regards,
Jayadev
There is a simple solution:
Please try this before saving:
if !IsReadOnly(cXlFileNameWithFullPath)
oSheet1:SaveAs(cXlFileNameWithFullPath)
endif
FUNCTION IsReadOnly(cFile)
LOCAL nOpen := fopen(cFile,FO_EXCLUSIVE)
// if cFile is already open, nOpen will be -1
if nOpen != -1
FClose(nOpen)
endif
RETURN nOpen = -1
HTH,
Warm regards,
Jayadev
- serge_girard
- Posts: 3165
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Error on oSheet1:SaveAs(cFILE_NAME)
Thanks Jayadev !
I will try.
Clipmania's oExcel:DisplayAlerts := 0 seems work also.
Thanks again, Serge
I will try.
Clipmania's oExcel:DisplayAlerts := 0 seems work also.
Thanks again, Serge
There's nothing you can do that can't be done...