Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problems with VFP and Excel 2000?...
Message
 
À
26/12/1999 22:32:20
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00308023
Message ID:
00308893
Vues:
71
>Yes, that will help. Send me the class code....

Here it is. All you'll have to do to test is change the file name to one that exists
* The class code
DEFINE CLASS XLDemo AS CUSTOM

  oServer = NULL
  oSpreadsheet = NULL
  oWorkbook = NULL
  oRange = NULL

  PROCEDURE Init

    This.oServer = CREATEOBJECT("Excel.Application")
    RETURN NOT ISNULL(This.oServer)
  ENDPROC
  
  PROCEDURE CreateCursor
	  
    RETURN
  ENDPROC

  PROCEDURE MinimizeApp
	
    This.oServer.WindowState = -4140
    RETURN
  ENDPROC

  PROCEDURE MaximizeApp

    This.oServer.WindowState = -4137
    RETURN
  ENDPROC

  PROCEDURE GetRangeObject
    
    LOCAL lcrange
	lcrange = This.oServer.Selection.Address(.F., .F., 1)
	This.oRange = This.oWorkBook.ActiveSheet.Range(lcrange)
	RETURN
  ENDPROC

  PROCEDURE OpenFile
    
    LPARAMETER pcfilename

    This.oWorkBook = This.oServer.Workbooks.Open(pcfilename)
    RETURN
  ENDPROC

  PROCEDURE MakeAppVisible
    
    This.oServer.Visible = .T.
    RETURN
  ENDPROC

  PROCEDURE CloseApplication

    This.oServer.Quit()
    RETURN
  ENDPROC

  PROCEDURE TransferData

    LOCAL loCell, loRange
    This.CreateCursor
    This.GetRangeObject
    loRange = This.oRange
    FOR EACH loCell IN loRange
    NEXT
    STORE NULL TO loCell, loRange
    RELEASE loCell, loRange
    RETURN
  ENDPROC
  
  PROCEDURE Destroy
    
    STORE NULL TO This.oServer,;
      This.oSpreadsheet,;
      This.oWorkbook,;
      This.oRange
    RETURN
  ENDPROC
ENDDEFINE

* The program to call it
LOCAL oExcel
lcfile = 'C:\LOTUS97\123\WARPING1.WK4'
SET PROCEDURE TO XL_DEMO ADDITIVE
oExcel = CREATEOBJECT('XLDemo')
RELEASE PROCEDURE XL_DEMO
oExcel.OpenFile(lcfile)
oExcel.MinimizeApp
oExcel.MakeAppVisible
_SCREEN.WindowState = 1
oExcel.MaximizeApp
DO WHILE oExcel.oServer.WindowState = -4137
ENDDO
_SCREEN.WindowState = 2
oExcel.TransferData
oExcel.CloseApplication
oExcel = NULL
RELEASE oExcel
You can get rid of the reference to Excel that'll appear in the task manager by issuing CLEAR ALL.

Thanks for taking a look guys,
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform