Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Visual FoxPro 5.0 and Excel'97
Message
From
13/05/1998 12:05:49
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
13/05/1998 10:51:32
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00099044
Message ID:
00099077
Views:
26
>Hi,
>
>I have a problem with OLE instances of Excel. . .
>
>I'm creating an OLE instance of Excel for reporting purposes(using: thisform.oExcel=CREATEOBJECT("Excel.Application")), which I am then able to write data to and manipulate via OLE. The user can save this and then if he wants, shut down Excel.
>
>However, if after the user has manually closed Excel, he then attempts (in the same session) to write to Excel for a second time. The system loads an instance of Excel that seems to be ScreenLocked (for want of a better description) and does not show the new workbook. - You get a GUI scenario similar to that after issuing thisform.screenlock =.T. in VFP.
>
>In VFP I have tried detecting for a .null. object or even testing the type of "thisform.oExcel.name" - hoping that it might be "U" if excel has been closed down. - Even though excel is closed this still returns "C".
>
>I assume that my object handle in VFP "won't let go of Excel", so how do I detect that Excel has been closed? or How do I re-establish a closed instance of Excel, so that I can re-use it?
>
>Any help would be much appreciated.
>
>Regards,
>
>James.
James,
Try with this :
**************************************************
*-- Class:        excelcaller (c:\temp\test.vcx)
*-- ParentClass:  commandbutton
*-- BaseClass:    commandbutton
*
DEFINE CLASS excelcaller AS commandbutton


	Height = 27
	Width = 84
	Caption = "Launch Excel"
	Name = "excelcaller"


	PROTECTED PROCEDURE findwindowclass
		lparameters tcWintitle
		DECLARE integer FindWindow in WIN32API string cNull, string cWinName
		declare integer GetClassName in WIN32API integer hWnd, string @cClass, integer nMaxBuffer
		hWnd = FindWindow(0,tcWintitle)
		lpClassName = space(200)
		nBufLen = GetClassName(hWnd,@lpClassName,200)
		clear dlls
		return substr(lpClassName,1,nBufLen)
	ENDPROC
	PROTECTED PROCEDURE findwindowhandle
		lparameter tcWinClass
		DECLARE integer FindWindow in WIN32API string cNull, string cWinName
		nHWND = FindWindow(tcWinClass,0)
		clear dlls
		return nHWND
	ENDPROC


	PROCEDURE Click
		Public oExcel
		oExcel = GetObject('','excel.sheet')
		for ix = 1 to 20
		  	tcWaitWindowClass = this.findwindowclass("Microsoft Excel")
		  	if !empty(tcWaitWindowClass)
		  		exit
		   	endif
		endfor
		oExcel.Application.Visible = .t.
		do while this.findwindowhandle(tcWaitWindowClass)<>0
		enddo
		release oExcel
	ENDPROC


ENDDEFINE
*
*-- EndDefine: excelcaller
**************************************************
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform