Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Odd issue with Excel automation / ShellExec
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Miscellaneous
Thread ID:
01531743
Message ID:
01531745
Views:
30
Naomi - thanks for the reply. It does work out at the command prompt. Thanks for the FINALLY tip. My other calls to ShellExec (for DOC and PDF document displays) use macros and they work fine. But i'll make the switch.

>If you try to run ShellExec with the file name separately (just a test separate program), does it work?
>
>Also, you better add the close and quit in the Finally clause of the try/catch.
>
>Finally, don't use macros here at all. Directly use ShellExec(m.lcXLSfile)
>
>>I am creating excel spreadsheets with VFP automation and all fine. However, i am trying to use Rick S's SHELLEXEC to display the created XLS file. The XLS file is created, the foxpro excel automation session is ended and then SHELLEXEC is called in order for the user to display the file. The problem is that the excel file is opened in Excel but its basically blank. If i close excel and use windows explorer to open the file, the entire file is there as it should be. It appears to be some type of timing issue.
>>
>>If i use oExcel.Visible = .t., the file displays correctly but i was hoping to close the automation session so that i dont leave some orphaned sessions around.
>>
>>This ShellExec works well for other docs (DOC, PDF) but there appears to be a timing issue in this case. And the correct file is being opened by ShellExec. It looks like just one cell is populated. I have added some FOPEN and FFLUSH commands in attempt to remedy the problem, but no joy. Any ideas?
>>
>>
>>	IF TYPE("oExcel") = "O"
>>	        TRY
>>			oExcel.quit()
>>		CATCH
>>		ENDTRY
>>		RELEASE oExcel
>>		oExcel = .NULL.
>>	ENDIF
>>	
>>	FLUSH
>>	
>>	*--- if save worked, ask if they want to view the file
>>	IF ! llFailSave 
>>		IF FILE("&lcXLSfile")
>>		       TRY
>>				lnFile = FOPEN("&lcXLSfile",12)
>>				IF lnFile > 0
>>					=FFLUSH(lnFile,.t.)
>>					=FCLOSE(lnFile)
>>				ENDIF
>>			CATCH
>>			ENDTRY
>>		
>>			*--- try to open it via ShellExec procedure
>>			TRY
>>				shellexec("&lcXLSfile")
>>			CATCH
>>				lcMsg = MESSAGE()
>>				=MESSAGEBOX("An error occured while attempting to open...")
>>			ENDTRY
>>
Previous
Reply
Map
View

Click here to load this message in the networking platform