IF lErrorFlag
ON ERROR &cError
SET STEP ON
MESSAGEBOX(CANTOPENWORKBOOK_LOC, 0 + 16, APPNAME_LOC)
SELECT (lnOldSelect)
RETURN
ENDIF
IF "maintform" $ THISFORM.PARENTCLASS
lcName = STRTRAN(LEFT(THISFORM.CAPTION, LEN(THISFORM.CAPTION) -2), " ", "_")
ELSE
lcName = THISFORM.CAPTION
ENDIF
lcName = CHRTRAN( lcName, 'á', 'a')
lcName = CHRTRAN( lcName, 'é', 'e')
lcName = CHRTRAN( lcName, 'í', 'i')
lcName = CHRTRAN( lcName, 'ó', 'o')
lcName = CHRTRAN( lcName, 'ú', 'u')
lcName = CHRTRAN( lcName, ',', '_')
lcFileName = ALLTRIM(GoApp.GetSetting(EXCELDIR_KEY, APPCLASS)) + ;
lcName + ;
ALLTRIM(STR(THISFORM.nExcelCount)) + ".XLS"
SET SAFETY OFF
COPY TO ( lcFileName) TYPE XL5 FIELD EXCEPT *D
cError = ON("ERROR")
lErrorFlag = .F.
ON ERROR lErrorFlag = .T.
COPY TO ( lcFileName) TYPE XL5 FIELD EXCEPT *D
ON ERROR &cError
IF lErrorFlag
ERRORMSG("No se pudo generar la planilla, asegurece por favor que no esta siendo utilizada por una sesión de MS-Excel")
RETURN .F.
ENDIF