FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour No exported method: SAVEAS
Posts: 149
Joined: Thu Jun 21, 2007 03:26 PM
No exported method: SAVEAS
Posted: Thu May 06, 2010 08:53 PM

Hola, me da un error al usar el fwh 10.4 o 10.3; con el 8.03 me funcionaba bien. Corre el programa, y la segunda vez que ejecuto el excel, me da error (el que pego luego del código). Código (básicamente abro un excel, le configuro que no avise nada, le genero columnas y filas, y luego quiero grabar; en ese lugar me da error):

oExcel := CREATEOBJECT( "Excel.Application" )
//oExcel:WorkBooks:Open( xruta )
OEXCEL:DISPLAYALERTS=.F.

oWorkBook := oExcel:WorkBooks:Add()

oSheet := oExcel:ActiveSheet

// ****

DO CASE
CASE XORDEN=1
oSheet:Cells( 1, 1 ):Value = "Codigo"
oSheet:Cells( 1, 2 ):Value = "Descripcion"
oSheet:Cells( 1, 3 ):Value = "Cod.Linea"
oSheet:Cells( 1, 4 ):Value = "Des.Linea"
oSheet:Cells( 1, 5 ):Value = "Cod.Rubro"
oSheet:Cells( 1, 6 ):Value = "Des.Rubro"

XFILA:=1
XCOL:=7
CASE XORDEN=2
oSheet:Cells( 1, 1 ):Value = "Cod.Linea"
oSheet:Cells( 1, 2 ):Value = "Des.Linea"

XFILA:=1
XCOL:=3
CASE XORDEN=3
oSheet:Cells( 1, 1 ):Value = "Codigo"
oSheet:Cells( 1, 2 ):Value = "Descripcion"

XFILA:=1
XCOL:=3

ENDCASE

oWorkbook:SaveAs( xruta )

oExcel:Quit()
oExcel:=NIL

ERROR:

Application

Path and name: c:\FW192\SAROSSX\REP_CLI.EXE (32 bits)
Size: 2,019,840 bytes
Time from start: 0 hours 1 mins 28 secs
Error occurred at: 06-05-2010, 09:37:28
Error description: Error BASE/1004 No exported method: SAVEAS
Args:
[ 1] = A { ... }
[ 2] = C C:\USERS\ADMIN\DOCUMENTS\VTAANIO.XLS

Stack Calls

Called from: => SAVEAS(0)
Called from: rep_cli.prg => IM_C_MXM(12820)
Called from: rep_cli.prg => (b)CLI_R_MXM(11989)
Called from: .\source\classes\BUTTON.PRG => TBUTTON:CLICK(176)
Called from: .\source\classes\CONTROL.PRG => TBUTTON:HANDLEEVENT(1446)
Called from: .\source\classes\WINDOW.PRG => _FWH(3378)
Called from: => SENDMESSAGE(0)
Called from: .\source\classes\DIALOG.PRG => TDIALOG:COMMAND(408)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT(944)
Called from: => DIALOGBOX(0)
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE(273)
Called from: rep_cli.prg => CLI_R_MXM(11992)
Called from: rep_cli.prg => REPCL(174)
Called from: rep_cli.prg => MAIN(86)

Por favor, si pueden darme una mano, se los agradecere. Atte.

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: No exported method: SAVEAS
Posted: Thu May 06, 2010 09:25 PM

Diego,

Parece que en vez de haber un objeto ahí, hay un array. Prueba esto:

oWorkBook := oExcel:WorkBooks:Add()
MsgInfo( ValType( oWorkBook ) )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: No exported method: SAVEAS
Posted: Fri May 07, 2010 05:40 AM

diegopolverelli ,

The error may be because of the path problem in the variable xruta. :) For eg. Invalid path or access rights problem in the specified path. You may also check whether another excel instance is running in the background and the excel file specified in the variable xruta is already open in the memory

Regards
Anser

Posts: 149
Joined: Thu Jun 21, 2007 03:26 PM
Re: No exported method: SAVEAS
Posted: Fri May 07, 2010 11:35 AM

Hola, Antonio: me aparece un cartelito que dice "O" (la letra O). Ahora, si corro varias veces el programa, antes de fallar, el cartelito dice "A", así que calculo que cuando falla el objeto es un ARRAY ¿ayuda en algo? ¿que se puede hacer para que no me lo arme como un array?
Ademá me extraña porque compilo con la versión 8.03 y funciona perfecto.

Hola, Anserkk: si el path es incorrecto, o el archivo está en uso, el error es otro (error de argumento en save as). ¿como puedo hacer para consultar si la hay una instancia de excel abierta en memoria con el nombre xruta?
"You may also check whether another excel instance is running in the background and the excel file specified in the variable xruta is already open in the memory"
¿como se hace eso? ¿con que código?

Gracias.

Posts: 128
Joined: Wed Oct 26, 2005 12:18 PM
Re: No exported method: SAVEAS
Posted: Sat May 08, 2010 04:50 AM

Los parámetros Workbook:SaveAs() son:

SaveAs(Filename, FileFormat, Password, WriteResPassword, ReadOnlyRecommended, CreateBackup, AccessMode, ConflictResolution, AddToMru, TextCodepage, TextVisualLayout, Local)

Donde los dos primeros parámetros son requeridos, aunque el manual diga otra cosa.

A mí me funciona así:

define xlNormal -4143

::oBook:SaveAs(::cFile,xlNormal,"","",.F.,.F.)

donde ::cFile, además debe ser el nombre completo, con path y todo.

Saludos cordiales.

Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: No exported method: SAVEAS
Posted: Sat May 08, 2010 06:06 AM
Diegopolverelli ,

diegopolverelli wrote:Hola, Anserkk: si el path es incorrecto, o el archivo está en uso, el error es otro (error de argumento en save as). ¿como puedo hacer para consultar si la hay una instancia de excel abierta en memoria con el nombre xruta?
"You may also check whether another excel instance is running in the background and the excel file specified in the variable xruta is already open in the memory"
¿como se hace eso? ¿con que código?


Code (fw): Select all Collapse
#include "Fivewin.ch"
//----------------------------------//
Function Main()
    
      Local oExcel,oWorkBook,oSheet,oRange,i,cFileName:="D:\FwhTests\MyTest"
    
    TRY
        // Checking whether the excel instance is already open or not
        oExcel   := GetActiveObject( "Excel.Application" )
    CATCH
         MsgInfo("No active Excel instance found, so creating a new instance")
         TRY
             oExcel   := CreateObject( "Excel.Application" )
         CATCH
         END   
     END

    // Check whether the WorkBook is already Open or Not
    if IsWorkBookOpen(oExcel,cFileName,.T.)
        MsgInfo(cFileName+" was already open, Now I have closed the workbook via PRG")
    Endif

    oExcel:DISPLAYALERTS=.F.
    
    oWorkBook := oExcel:WorkBooks:Add()
    oSheet := oExcel:ActiveSheet
    
    // Add main Heading    
    oSheet:Cells(1,1):Value:="My Heading"
    
    // Add Column headings
    oSheet:Cells( 2, 1 ):Value = "Date"
    oSheet:Cells( 2, 2 ):Value = "Number"
    oSheet:Cells( 2, 3 ):Value = "Description"
    oSheet:Columns(3):ColumnWidth:=50
    oSheet:Cells( 2, 4 ):Value = "Amount"
    
    For i:=3 to 10
        oSheet:Cells(i,1):Value=Date()
        oSheet:Cells(i,2):Value=i
        oSheet:Cells(i,3):Value="Description "+str(i,2)
        oSheet:Cells(i,4):Value=i*10
    Next
    
    // Create Merged cells
    oRange:=oSheet:Range("A1:D1")
    oRange:MergeCells:= .T.
    oRange:HorizontalAlignment:= -4108  // xlCenter
    oRange:Font:Bold:=.T.

    oWorkbook:SaveAs( cFileName )
    
    oExcel:Quit()
    oExcel:=NIL

Return NIL

//---------------------------------------------//
Function IsWorkBookOpen(oExcel,cFileName,lClose)

    Local nFiles,i
    nFiles:=oExcel:Workbooks:Count()
    For i:=1 to nFiles
        If Upper(oExcel:Workbooks[i]:Path + "\" + oExcel:Workbooks[i]:Name) = Upper(cFileName)
            if lClose  // Close the WorkBook
                oExcel:Workbooks[i]:Close() 
            Endif
            Return .T.
        Endif
    Next
    
Return .F.


Regards
Anser
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: No exported method: SAVEAS
Posted: Sat May 08, 2010 07:11 AM

Diego,

Lo que cuenta es la versión de Harbour ó xHarbour usada, FWH no interviene en la creación de ese objeto.

Si en un determinado momento sale una "A" en vez de una "O" algo está fallando y es dificil determinar que pueda ser.

Tendrias que proporcionar un pequeño ejemplo que reproduzca el error y que no use FWH, para que se lo podamos pasar a la lista de desarrollo de Harbour/xHarbour y que se revise el problema.

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion