Mini Kabibi Habibi

Current Path : C:/Users/ITO/Desktop/VF9/program files/microsoft visual foxpro 9/samples/solution/ole/
Upload File :
Current File : C:/Users/ITO/Desktop/VF9/program files/microsoft visual foxpro 9/samples/solution/ole/oleaut1.sct

0lVERSION =   3.00dataenvironmentdataenvironmentDatanavigationName = "Datanavigation"
12formform
oleautform�DataSession = 2
Height = 109
Width = 328
DoCreate = .T.
AutoCenter = .T.
Caption = "Automate Microsoft Word and Excel"
MaxButton = .F.
MinButton = .T.
HelpContextID = 193
Name = "oleautform"
PROCEDURE soln_escape_handler
#DEFINE err_teminate_loc	"Would you like to terminate automation sample now?"
IF MESSAGEBOX(err_teminate_loc,36)=6
	RETURN TO CALLSAMPLE
ENDIF

ENDPROC
PROCEDURE callsample
LOCAL nlLocaleId
*** set the LOCALEID to English
nlLocaleId=sys(3004)
=sys(3006,1033)

SET ESCAPE ON
IF TYPE("_screen.activeform")="O" and !ISNULL(_screen.activeform)
	LOCAL cEscapeHandler 
	cEscapeHandler = "_screen.activeform.soln_escape_handler"
	ON ESCAPE &cEscapeHandler
ENDIF

THIS.RunSample()

IF EMPTY(THIS.cOnEscape)
	ON ESCAPE
ELSE
	cTmpEscape = THIS.cOnEscape
	ON ESCAPE &cTmpEscape
ENDIF
**** Reset the LocaleId to the previous value
=sys(3006,val(nlLocaleId))

ENDPROC
PROCEDURE runsample
*:*********************************************************************
*:
*: 		Form file: \SAMPLES\OLE\OLEAUT1.SCX
*:
*:         System: OLE
*:         Author: Microsoft Corporation
*:		  Created: 10/24/94
*:	Last modified: 05/25/95
*:
*:
*:*********************************************************************
* This  is an example of OLE Automation, and it demonstrates how to
* select data from a FoxPro database, place the data in
* an Excel spreadsheet, graph the data using Chart, and then display
* the graph in Word.  To use this example, you need Excel 5.0c,
* Word 6.0a, and TESTDATA.DBC!customer.dbf, located in your FoxPro \SAMPLES\DATA
* directory.
*
* To run this example, type DO FORM OLEAUT1.SCX
* in the Command window.
*
***********************************************************************
** Localization strings

#DEFINE WAITMESSAGE1_LOC 			"Performing Query..."
#DEFINE WAITMESSAGE2_LOC 			"Creating Excel Spreadsheet...."
#DEFINE WAITMESSAGE3_LOC 			"Placing Query Info into Spreadsheet..."
#DEFINE WAITMESSAGE4_LOC 			"Creating Graph Object...."
#DEFINE WAITMESSAGE5_LOC 			"Creating Graph..."
#DEFINE WAITMESSAGE6_LOC 			"Creating Word Document..."
#DEFINE WAITMESSAGE7_LOC 			"Done!"

#DEFINE APPSHOW_WORDUS_LOC			"appshow"
#DEFINE FILENEW_WORDUS_LOC			"filenewdefault"
#DEFINE INSERT_WORDUS_LOC			'insert("Here is your graph!")'
#DEFINE EDITPASTESPECIAL_WORDUS_LOC	"editpastespecial(,,,,'PICT')"
#DEFINE	OBJECT_TYPE					"OBJECT"

**** Define tokenized Word 6.0 commands, since Word 6.0 does not
**** English Automation commands.
APPSHOW_WORDUS			=APPSHOW_WORDUS_LOC
FILENEW_WORDUS			=FILENEW_WORDUS_LOC
INSERT_WORDUS			=INSERT_WORDUS_LOC
EDITPASTESPECIAL_WORDUS	=EDITPASTESPECIAL_WORDUS_LOC
**********************************************************************

PUBLIC ObjWDdoc

LOCAL lcDataDir
lcDataDir = HOME(2)
DO CASE
CASE FILE(HOME(2)+"data\testdata.dbc")
	lcDataDir = HOME(2)
CASE FILE(HOME()+"samples\data\testdata.dbc")
	lcDataDir = HOME() + "Samples\"
OTHERWISE
	MESSAGEBOX(DATAERR_LOC)
	RETURN .F.
ENDCASE

wait wind WAITMESSAGE1_LOC nowait
SELECT city, count(city) ;
	FROM (lcDataDir + "data\testdata!customer") ;
	GROUP BY city ;
	HAVING COUNT(city) > 1 ;
	INTO array cust_distrib

wait wind WAITMESSAGE2_LOC nowait
objXLsheet=CreateObject("Excel.Sheet")
objXLsheet.application.visible=.T.

* Excel 97 Automation change
* CreateObject() returns Object instead of Sheet1
IF UPPER(objXLsheet.Name)=OBJECT_TYPE
	lHasExcel97 = .T.
	objXLsheet = objXLsheet.Sheets[1]
ELSE
	lHasExcel97 = .F.
ENDIF

Wait wind WAITMESSAGE3_LOC nowait
*** Copy data to an excel spreadsheet
for i = 1 to _TALLY
	objXLsheet.Cells(i,1).Value = cust_distrib(i,1)
	objXLsheet.Cells(i,2).Value = cust_distrib(i,2)
endfor

Wait wind WAITMESSAGE4_LOC nowait

*** Add a ChartObject to the worksheet:
objChart1 = objXLsheet.ChartObjects.Add(100, 100, 200, 200)

*** Create the chart.
*** NOTE: Parameters for chartwizard can be found in the Excel VBA
*** help file. Definitions of xlConstants are found in xlconst.bas
*** which is included with the Office Developer's Kit
***
*** The parameters for some server functions are sometimes hard to
*** find (like chartwizard). The best way to find the correct parameters
*** is to record the same steps as macro in the server application.
*** Then edit the macro and copy the parameters
*** and paste them into Visual FoxPro.

Wait wind WAITMESSAGE5_LOC nowait
objxlsheet.chartobjects(1).chart.;
	chartwizard(objxlsheet.range(objxlsheet.cells(1,1),objxlsheet.cells(10,2)),;
	-4100,4,1,0,1,1,"","","","")

ObjXLsheet.ChartObjects(1).select
ObjXLsheet.ChartObjects(1).copy

IF !m.lHasExcel97
	objXLsheet.application.quit
ENDIF
release objXLsheet

Wait wind WAITMESSAGE6_LOC nowait
objWDdoc=crea("word.basic")
objwddoc.&APPSHOW_WORDUS	&&added 8/17 for Word 7.0 support
objwddoc.&FILENEW_WORDUS
objwddoc.&INSERT_WORDUS

**** Because the excel objects were already RELEASEd
**** the graph must be pasted w/o a link.
**** It is pasted as a PICTURE instead of a GRAPH
**** To paste as a link, you would use this command
**** objWDdoc.editpaste
**** AND you would have to make sure the Excel Objects
**** were not RELEASEd and that Excel was still running

objwddoc.&EDITPASTESPECIAL_WORDUS
Wait Wind WAITMESSAGE7_LOC nowait

ENDPROC
PROCEDURE Deactivate
IF TYPE("THIS.c_solutions1") = "O" THEN
	THIS.c_solutions1.restoreHelp
ENDIF
IF THIS.cOldEscape = "OFF"
	SET ESCAPE OFF
ENDIF
IF EMPTY(THIS.cOnEscape)
	ON ESCAPE
ELSE
	cTmpEscape = THIS.cOnEscape
	ON ESCAPE &cTmpEscape
ENDIF

ENDPROC
PROCEDURE Activate
THIS.c_solutions1.saveHelp

ENDPROC
PROCEDURE Init
IF  fontmetric(1, 'MS Sans Serif', 8, '') # 13 OR ;
	fontmetric(4, 'MS Sans Serif', 8, '') # 2 OR ;
	fontmetric(6, 'MS Sans Serif', 8, '') # 5 OR ;
	fontmetric(7, 'MS Sans Serif', 8, '') # 11
	this.setall('fontname', 'Tahoma')  
ELSE
	this.setall('fontname','MS Sans Serif')
ENDIF
this.setall('fontsize',8)

THIS.cOldEscape = SET("ESCAPE")
THIS.cOnEscape = ON("ESCAPE")
ENDPROC
��� jj�%�
�b
�UXI%�C�2Would you like to terminate automation sample now?�$�x���Q�B(���U
CALLSAMPLE*���T��C��]����C���	]��G �2%�C�_screen.activeformb�O�	C�9��
	�������3T���&_screen.activeform.soln_escape_handler��ON ESCAPE &cEscapeHandler
�
��C����%�C�������{�����T������ON ESCAPE &cTmpEscape
���C��C�g]��U
NLLOCALEID
ACTIVEFORMCESCAPEHANDLERTHIS	RUNSAMPLE	CONESCAPE
CTMPESCAPE�T���appshow��T���filenewdefault��*T���insert("Here is your graph!")��)T���editpastespecial(,,,,'PICT')��7�����T��C��Q��
H���D�'�CC��Q�data\testdata.dbc0����T��C��Q��,�CC�Q�samples\data\testdata.dbc0��)�T��C�Q�Samples\��2�D���C��x��B�-���R,:��Performing Query...��Ko���data\testdata!customer�����C��������C������)R,:��Creating Excel Spreadsheet....��T�	�C�Excel.Sheet�N��T�	�
��a��%�C�	�f�OBJECT��A�T�
�a��T�	�C��	����T�T�
�-���1R,:��&Placing Query Info into Spreadsheet...�������(�� ����'T�	���������C�����'T�	���������C�������$R,:��Creating Graph Object....�� T��C�d�d����	����R,:��Creating Graph...��w��	�������CC���	�C�
��	��	������������������������������������	��������	������%��
�

���
��	�
���<�	�$R,:��Creating Word Document...��T��C�
word.basic�N��objwddoc.&APPSHOW_WORDUS	
objwddoc.&FILENEW_WORDUS
objwddoc.&INSERT_WORDUS
%objwddoc.&EDITPASTESPECIAL_WORDUS
R,:��Done!��UAPPSHOW_WORDUSFILENEW_WORDUS
INSERT_WORDUSEDITPASTESPECIAL_WORDUSOBJWDDOC	LCDATADIRDATAERR_LOCCITYCUST_DISTRIB
OBJXLSHEETAPPLICATIONVISIBLENAMELHASEXCEL97SHEETSICELLSVALUE	OBJCHART1CHARTOBJECTSADDCHARTCHARTWIZARDRANGESELECTCOPYQUIT�%%�C�THIS.c_solutions1b�O��2�
������%����OFF��S�G��%�C�����q�{������T������ON ESCAPE &cTmpEscape
�UTHISC_SOLUTIONS1RESTOREHELP
COLDESCAPE	CONESCAPE
CTMPESCAPE
�����UTHISC_SOLUTIONS1SAVEHELP:�%�C��
MS Sans Serif���$�
�!C��
MS Sans Serif���$��!C��
MS Sans Serif���$��!C��
MS Sans Serif���$�����!��C�fontname�Tahoma�������(��C�fontname�
MS Sans Serif�������C�fontsize�����T���C�ESCAPEv��T���C�ESCAPE���UTHISSETALL
COLDESCAPE	CONESCAPEsoln_escape_handler,��
callsample���	runsample��
Deactivate��Activate	��Init2	��1��A3qb!q1�A�"���A3�A���sr�q����qA������A��AbqqAB�s21�AqB����Z3Q�AqaA!���A3�3d	��A���1����!J6#�WB^�Yy��)jIcoldescape
conescape
*soln_escape_handler 
*callsample 
*runsample 

commandbutton
commandbuttonCommand1
oleautform�Top = 81
Left = 169
Height = 23
Width = 72
FontName = "MS Sans Serif"
FontSize = 8
Caption = "\<Run Example"
TabIndex = 1
Name = "Command1"
�PROCEDURE Error
Parameters nError, cMethod, nLine
=messagebox(message())
cancel

ENDPROC
PROCEDURE Click
THISFORM.CallSample()

ENDPROC
1�� ��%����U!4������CCE�x���UNERRORCMETHODNLINE
��C����UTHISFORM
CALLSAMPLEError,��Clicki��1��A3�2Tp�)behindscenes..\solution.vcx
commandbutton
Behindscenes1
oleautform;Top = 81
Left = 11
TabIndex = 3
Name = "Behindscenes1"
c_solutions..\solution.vcxcustomC_solutions1
oleautformETop = 85
Left = 41
Height = 18
Width = 25
Name = "C_solutions1"
cmdclose..\solution.vcx
commandbutton	Cmdclose1
oleautformQTop = 81
Left = 246
Height = 23
Width = 72
TabIndex = 2
Name = "Cmdclose1"
shapeshapeShape2
oleautformbTop = 13
Left = 10
Height = 58
Width = 309
BackStyle = 0
SpecialEffect = 0
Name = "Shape2"
labellabelLabel5
oleautformDFontName = "MS Sans Serif"
FontSize = 8
WordWrap = .T.
Caption = "To pass Microsoft Visual FoxPro data to Microsoft Excel for charting, then to Microsoft Word for displaying, Click Run Example.  (You must have all three products installed.)"
Height = 41
Left = 19
Top = 23
Width = 291
TabIndex = 0
Name = "Label5"
labellabelLabel6
oleautform�AutoSize = .T.
FontName = "MS Sans Serif"
FontSize = 8
Caption = " Instructions "
Height = 15
Left = 18
Top = 7
Width = 62
TabIndex = 0
Name = "Label6"
JArial, 0, 9, 5, 15, 12, 32, 3, 0
MS Sans Serif, 0, 8, 5, 13, 11, 11, 2, 0
�DataSession = 2
Height = 109
Width = 328
DoCreate = .T.
AutoCenter = .T.
Caption = "Automate Microsoft Word and Excel"
MaxButton = .F.
MinButton = .T.
HelpContextID = 1231579
Name = "oleautform"