Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Programmatically convert doc to PDF
Message
From
07/03/2004 22:24:30
 
 
To
20/01/2004 05:13:12
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00868423
Message ID:
00883972
Views:
14
hi fernando,

why am i getting "adobe reader could not open 'myword.pdf' because it is either not a supported file type or because the file has been corrupted (for example, it was sent as an email attachment and wasn't correctly decoded)." when i try to open the converted pdf?

i use this code,
infile="myWord.doc"

if file(infile)=.f.
    missingfile=messagebox("File no longer exists or was moved. Do you want to look for it?","Missing Input File",4)
    if missingfile=6
        infile=getfile()
    else
        return
    endif
endif

m.ext=upper(justext(infile))
do case
case m.ext=="DOC"
    typeoffile="WORD"
otherwise
    messagebox("Only File Extensions of 'DOC' are currently supported","File Error",0)
    return
endcase

if not directory("pdffiles")
    mkdir pdffiles
endif

psfile=sys(5)+sys(2003)+"\Output.PDF"
printertouse="PDF995"

lcdefaultprinter =  set("PRINTER",3)
strtofile(lcdefaultprinter,"oldprinter.txt")

pmissing="N"
on error pmissing="Y"
onet = createobject("WScript.Network")
onet.setdefaultprinter(printertouse)

if m.pmissing="Y"
    messagebox("Please Add Printer '"+printertouse+"' as a Print-to-File Printer"+chr(13)+;
        "using 'printers/faxes->add printer wizard' in the control pannel.","PS Printer Not Found",0)
    return
endif

on error do oldprinter

loword = createobject("Word.Application")
with loword
    .displayalerts = .f.
    .visible=.f.
    .documents.open(infile)
    .activedocument.printout(0,0,0,PSFile) 
    .quit
endwith
loword=.null.

onet.setdefaultprinter(lcdefaultprinter)

procedure oldprinter
lcdefaultprinter =  filetostr("oldprinter.txt")
onet = createobject("WScript.Network")
onet.setdefaultprinter(lcdefaultprinter)
messagebox("Error! Please Check Printer Driver and MS Office Availability."+chr(13)+;
    "printer returned to default.","Conversion to PS Error",0)
on error
endproc
noticed the line
.activedocument.printout(0,0,0,PSFile)
, i used this to programmatically name the pdf file.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform