Repost: PDF four versions of a document then delete interim saved Word files

M

Mike Starr

I posted this the other day but it seems to have fallen off the radar
screens because of the weekend.

Thanks

Mike

So I'm working on this template and the client wants it to have the ability
to make PDFs of four different versions of the same document... basically
changing the logo to reflect the different businesses that are part of the
corporation. Okay, I've got that all set up. A couple things are challenging
me, though.

1. I've got a button the user can click to generate the four different PDFs.
In order to do so, I have to give the document a different file name for
each one, otherwise when I create the PDFs it would just overwrite the same
PDF file and I'd only end up with one. So I modify the filename and do a
"Save As..." and everything's cool.

However, I'm unable to pass the path to the Acrobat Distiller printer so I
have to have the user manually browse to the directory where the PDF files
should be saved.

Anyone know of a way I can programmatically pass the appropriate path to the
Acrobat Distiller print dialog? Of course, I'd rather not have to have the
Acrobat Distiller print dialog display at all but it doesn't seem there's a
way to just have it all happen under the hood. Any pointers would be
welcome.

2. Because I'm doing the "Save As...", I'm ending up with four separate .DOC
files. When I create the file I initially save it with a compound filename,
consisting of a filename string the user provides (I put up a dialog box
requiring the user to enter a filename) with a string representing the
initial logo. So, for example, the initial file might be named
"Document1-logo1.doc". When I go through the PDF process, I modify the
filename to reflect the change of the logo and do a "Save As...", ending up
with three other files... "Document1-logo2.doc", "Document1-logo3.doc" and
"Document1-logo4.doc". So the process is as follows:

*Create "Document1-logo1.doc"
*Print "Document1-logo1.doc" to Acrobat Distiller printer, yielding the
default filename of "Document1-logo1.pdf"
*Save as "Document1-logo2.doc"
*Print "Document1-logo2.doc" to Acrobat Distiller printer, yielding the
default filename of "Document1-logo2.pdf"
*Save as "Document1-logo3.doc"
*Print "Document1-logo3.doc" to Acrobat Distiller printer, yielding the
default filename of "Document1-logo3.pdf"
*Save as "Document1-logo4.doc"
*Print "Document1-logo4.doc" to Acrobat Distiller printer, yielding the
default filename of "Document1-logo4.pdf"

The client wants the process to end up with only the original file
("Document1-logo1.doc"), so I need to delete "Document1-logo2.doc",
"Document1-logo3.doc" and "Document1-logo4.doc". I store the fully-qualified
filenames that I've used as strings named "killfile1", "killfile2" and
"killfile3" but when I attempt to delete the files using the language "kill
killfile1" I get a "Runtime error '70', Permission denied". So it appears
that I've got the instruction correct but there's something that prevents me
from actually deleting the file.

So my second question is how do I avoid the "Runtime error '70', Permission
denied"? Or is there a way I can pass the preferred PDF filename and path
directly to the Acrobat Distiller printer driver so I never have to do a
"Save As..." to the Word document??

3. When I create the file initially, the filename I use is constructed from
user input (from the example above, the user would have typed "Document1" in
the dialog box I put up) with a representative logo string ("-logo1"). If,
at some point in the future, the user wants to revise the document, they'll
open "Document1-logo1.doc". Now I have a problem because I don't have a
user-entered string stored ("Document1"). So if they then click the PDF
button, they end up with:

"Document1-logo1.doc"
"Document1-logo1.pdf"
"Document1-logo1-logo2.doc"
"Document1-logo1-logo2.pdf"
"Document1-logo1-logo3.doc"
"Document1-logo1-logo3.pdf"
"Document1-logo1-logo4.doc"
"Document1-logo1-logo4.pdf"

And my file deletion code fails because it's never able to construct the
proper "killfile1", "killfile2" and "killfile3" strings.

<arggh>

Any suggestions??

Thanks

Mike

--
Mike Starr WriteStarr Information Services
Technical Writer - Online Help Developer - Technical Illustrator
Graphic Designer - Desktop Publisher - MS Office Expert
(262) 694-1028 - (e-mail address removed) - http://www.writestarr.com



--
 
J

Jezebel

Did you not like the answer you got last time?



Mike Starr said:
I posted this the other day but it seems to have fallen off the radar
screens because of the weekend.

Thanks

Mike

So I'm working on this template and the client wants it to have the
ability
to make PDFs of four different versions of the same document... basically
changing the logo to reflect the different businesses that are part of the
corporation. Okay, I've got that all set up. A couple things are
challenging
me, though.

1. I've got a button the user can click to generate the four different
PDFs.
In order to do so, I have to give the document a different file name for
each one, otherwise when I create the PDFs it would just overwrite the
same
PDF file and I'd only end up with one. So I modify the filename and do a
"Save As..." and everything's cool.

However, I'm unable to pass the path to the Acrobat Distiller printer so I
have to have the user manually browse to the directory where the PDF files
should be saved.

Anyone know of a way I can programmatically pass the appropriate path to
the
Acrobat Distiller print dialog? Of course, I'd rather not have to have the
Acrobat Distiller print dialog display at all but it doesn't seem there's
a
way to just have it all happen under the hood. Any pointers would be
welcome.

2. Because I'm doing the "Save As...", I'm ending up with four separate
.DOC
files. When I create the file I initially save it with a compound
filename,
consisting of a filename string the user provides (I put up a dialog box
requiring the user to enter a filename) with a string representing the
initial logo. So, for example, the initial file might be named
"Document1-logo1.doc". When I go through the PDF process, I modify the
filename to reflect the change of the logo and do a "Save As...", ending
up
with three other files... "Document1-logo2.doc", "Document1-logo3.doc" and
"Document1-logo4.doc". So the process is as follows:

*Create "Document1-logo1.doc"
*Print "Document1-logo1.doc" to Acrobat Distiller printer, yielding the
default filename of "Document1-logo1.pdf"
*Save as "Document1-logo2.doc"
*Print "Document1-logo2.doc" to Acrobat Distiller printer, yielding the
default filename of "Document1-logo2.pdf"
*Save as "Document1-logo3.doc"
*Print "Document1-logo3.doc" to Acrobat Distiller printer, yielding the
default filename of "Document1-logo3.pdf"
*Save as "Document1-logo4.doc"
*Print "Document1-logo4.doc" to Acrobat Distiller printer, yielding the
default filename of "Document1-logo4.pdf"

The client wants the process to end up with only the original file
("Document1-logo1.doc"), so I need to delete "Document1-logo2.doc",
"Document1-logo3.doc" and "Document1-logo4.doc". I store the
fully-qualified
filenames that I've used as strings named "killfile1", "killfile2" and
"killfile3" but when I attempt to delete the files using the language
"kill
killfile1" I get a "Runtime error '70', Permission denied". So it appears
that I've got the instruction correct but there's something that prevents
me
from actually deleting the file.

So my second question is how do I avoid the "Runtime error '70',
Permission
denied"? Or is there a way I can pass the preferred PDF filename and path
directly to the Acrobat Distiller printer driver so I never have to do a
"Save As..." to the Word document??

3. When I create the file initially, the filename I use is constructed
from
user input (from the example above, the user would have typed "Document1"
in
the dialog box I put up) with a representative logo string ("-logo1"). If,
at some point in the future, the user wants to revise the document,
they'll
open "Document1-logo1.doc". Now I have a problem because I don't have a
user-entered string stored ("Document1"). So if they then click the PDF
button, they end up with:

"Document1-logo1.doc"
"Document1-logo1.pdf"
"Document1-logo1-logo2.doc"
"Document1-logo1-logo2.pdf"
"Document1-logo1-logo3.doc"
"Document1-logo1-logo3.pdf"
"Document1-logo1-logo4.doc"
"Document1-logo1-logo4.pdf"

And my file deletion code fails because it's never able to construct the
proper "killfile1", "killfile2" and "killfile3" strings.

<arggh>

Any suggestions??

Thanks

Mike

--
Mike Starr WriteStarr Information Services
Technical Writer - Online Help Developer - Technical Illustrator
Graphic Designer - Desktop Publisher - MS Office Expert
(262) 694-1028 - (e-mail address removed) - http://www.writestarr.com



--
--
Mike Starr WriteStarr Information Services
Technical Writer - Online Help Developer - Technical Illustrator
Graphic Designer - Desktop Publisher - MS Office Expert
(262) 694-1028 - (e-mail address removed) - http://www.writestarr.com
 
M

Mike Starr

Jezebel

I liked the answer you posted well enough and I appreciate the time you
spent writing it up. However, the one answer you gave didn't resolve the
three issues I asked about. You see, this is a template that will be
distributed to the client's users. I don't have any access to the users'
machines so I can't exercise any control over their PDF conversion settings.
You didn't answer the question about deleting the files and you didn't
answer the question about managing the situation where I open an existing
file.

Thanks anyway.

Mike Starr
 
M

Mike Starr

What you suggested was indeed a simpler solution but again, I don't have
access to the users' PDF settings so I can't control their preferences with
respect to Acrobat Distiller. The only way the suggestion you offered will
work better than what I already have is if the users' PDF conversion
settings are set to not prompt for a filename. I can't make that happen.
Matter of fact, if I COULD control the users' PDF conversion settings, my
own solution would work flawlessly.

What I need are solutions that I can implement from Word alone.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top