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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

View VFP6 report in Adobe 5

Status
Not open for further replies.

DAKUZ

Programmer
Jul 30, 2008
3
US
A PDF file is created from a report file when it is selected from a grid. I get the error "OLE IDispatch exception code 0 from PDFDisplay: File not found." when sending the file to the OLECONTROL.LOADFILE method. The OLECONTROL is on the same form that has the grid of the reports to select. User needs to view it in Adobe Reader and then send it via email.
 
Well, the obvious question is: Does the file exist? Are you sure it's been created at the point at which you load it into the viewer?

You can easily check for that by calling FILE() at the appropriate time.

How are you creating the PDF file?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Yes, the file is there. It is created by the "pcl2pdf501.exe" program. The file is also placed in a variable "thepdf". The code checks to see if it exists by using the FILE() function before calling the LoadFile method. I have placed numerous "WAIT WINDOW" commands and they state that the file is found and where it is.

I can open the PDF file from Adobe Reader 5. The file is deleted when the program closes. I tried copying the file to another folder (PDFDirectory is a string - "J:\PROD\"):
COPY FILE &thepdf TO PDFDirectory + &thepdf

but I get this error:
Command contains unrecognized phrase/keyword.
 
Are you passing the fully-qualified filename to the Adobe viewer, or just the filename alone? Don't forget that ActiveX controls don't know anything about VFP's default directory or search path. It's possible that VFP knows the file exists because it is in the search path, but the viewer can't find it.

When passing the filename to the LoadFile, try wrapping it in a FULLPATH().

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
You mention 2 distinct problems (albeit possibly related).
1. OLE IDispatch error
2. Error with COPY FILE command execution

A suggestion for #2...

Just to clarify...
You are getting the error:
Command contains unrecognized phrase/keyword
when you execute the command:
COPY FILE &thepdf TO PDFDirectory + &thepdf

Depending on the path and/or file names - do they contain spaces, etc.
you might want to change your code to something like:
Code:
mcSource = thepdf
mcDestination = ADDBS(PDFDirectory) + thepdf

COPY FILE (mcSource) TO (mcDestination)

Using the parenthesis around the names will allow the inclusion of spaces within the paths and file names.

Good Luck,
JRB-Bldr
 
The suggestion for copying files worked. That was just incase I cold not get the report PDF file to come up in Adobe.

I tried sending the file in FULLPATH():
THIS.PARENT.OLECONTROL1.LOADFILE(FULLPATH("&thepdf"),1)

It did not matter if I use [] instead of quotes or if sent 0 intead of 1 or no value at all. I still got the "OLE IDispatch ... File not found." error.

I found a thread in the Forms, Classes & Controls forum that worked:
oShell = CREATEOBJECT("wscript.Shell")
APPLICATION.OleRequestPendingTimeout = 0
cFilename = Path & Filename
(This is what I used - FULLPATH("&thepdf"))
oShell.RUN(cFilename,1)

This brought up the selected file in Adobe Reader and I was able to email it.

Thank you for your help!

DAKUZ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top