Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating a PDF document from an open Excel Doc. in VFP
Message
 
To
09/03/2005 11:24:50
Pierre Sauve
Micro-Fox Canada Inc.
Montréal, Quebec, Canada
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00994029
Message ID:
00994077
Views:
25
If you do not have a choice to update to later Excel version, then the only option I see is to create an additional exe file where timer is looking for the print to file dialog, and if found, types appropriate key combination.

Something like this:
* body of your main program
oShell = CreateObject("WScript.Shell")
oShell.run("ysetfilename.exe")
oShell=null

oExcel=CreateObject("Excel.Application")
oExcel.visible=.T.
oExcel.Workbooks.OPen("c:\book1.xls")

oExcel.ActivePrinter = "Win2PDF on Ne00:"
oExcel.Activesheet.PrintOut(,,,,,.t.)

oExcel=null

Return
Stand alone exe file:
* body of stand alone ysetfilename.exe
if version(2)=0
	_screen.left=-5000
endif


PRIVATE oShell, Ltimer, Starttime

starttime=SECONDS()

oShell = CreateObject("WScript.Shell")
Ltimer=createobject("_Force",60000,1000)

read events

Ltimer=.NUll.
oShell=.Null.

Return
*----------------------------------------
Define class _Force as Timer
	Interval 	= 1000
	Name 		= "ForceOL"
	timeoutdef 	= 60000
	Procedure INIT
		Lparameter pnTimeOut, pInterval
		if type("pnTimeOut")="N"
			this.timeoutdef=pnTimeOut
		endif
		if type("pInterval")="N"
			this.Interval=pInterval
		ENDIF
	endproc
	Procedure Timer
		if oShell.AppActivate("Print to File")
			ERASE C:\temppdf.pdf
			oShell.SendKeys("C:\temppdf.pdf{ENTER}")
			CLEAR events
		ENDIF
		
		IF SECONDS()-starttime>=this.timeoutdef/1000
			clear events
		ENDIF
	Endproc
Enddefine 
You may make it more robostic with parameters and passing file name and key combination as needed.


>Effectively I have Excel 2000 (ver. 9)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform