Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show Excel spreadsheet on vfp form

Status
Not open for further replies.

ikh

Programmer
Apr 17, 2001
24
0
0
CA
Can anybody provide some examples on how to show Excel spreadsheet on vfp form.
Thank you.
 
Here is an example:
Code:
oForm1 = CREATEOBJECT('Form')  
oForm1.Closable = .F.  
oForm1.height = 300
oForm1.width = 400
oForm1.AddObject('cmdCommand1','cmdMyCmdBtn')
oForm1.AddObject("oleObject","oleExcelObject") 
oForm1.cmdCommand1.Visible=.T. 
oForm1.oleObject.Visible=.T.  
oForm1.oleObject.Height = 200
oForm1.oleObject.width = 350
oForm1.Show  
oForm1.oleObject.DoVerb(-1)  
READ EVENTS  
DEFINE CLASS oleExcelObject as OLEControl
   OleClass ="Excel.Sheet"  
   DocumentFile = GETFILE('xls') 
ENDDEFINE
DEFINE CLASS cmdMyCmdBtn AS CommandButton  
   Caption = '\<Quit' 
   Cancel = .T. 
   Left = 125 
   Top = 210  
   Height = 25  
   visible = .t.
   PROCEDURE Click
      CLEAR EVENTS  
ENDDEFINE


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Thank you Mike. It worked.
Now another thing: I have already a form to work with so if I add olecontrol (choosing insert new Microsoft Excel worksheet) to the form when in design mode my OleClass is "Excel.Sheet8" and Documentfile propery is read-only. How can specify now which Excel file to show?
Thank you.
 
Unfortunately this is one that only works programmatically, you have to define the OleClass with the documentfile already loaded.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
A quick search in the VFP9 BOL yields:
You set the DocumentFile property of a linked OLE object using the Insert Object dialog box when you initially add an OLE container to a form. You can also set this property when creating an OLE object using the APPEND GENERAL command or when defining the object in code as part of a class definition.
FWIW.

Mike Krausnick
Dublin, California
 
Thank you. It worked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top