Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Fri, 18 Nov 2005 09:33:32 -0600,    group: microsoft.public.word.vba.customization        back       


PDF four versions of a document then delete interim saved Word files   
I posted this the over in microsoft.public.word.vba.general but didn't
get what I needed so I thought I'd try here. The answer I got over there
was unworkable because I don't have access to the users' computers
to configure their PDF conversion settings.
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  -  mike@writestarr.com  -  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  -  mike@writestarr.com  -  http://www.writestarr.com
date: Fri, 18 Nov 2005 09:33:32 -0600   author:   Mike Starr

Re: PDF four versions of a document then delete interim saved Word files   
Do it in VBA code, setting a pointer in VBE to the Acrobat Distiller 
library.
Once the reference to this libary is set, you can use something similar to
below pseudo code to generate a PDF file in whatever location.
(note: set a reference to Scripting Runtime library for below code as well)

Dim oDistiller As New PdfDistiller
Dim fso As New FileSystemObject
Dim sTempFile As String
Dim sMyPDF_File As String


sTempFile = "c:\temp\" & fso.GetTempName()
sMyPDF_File = "Z:\Data\a\Abraham\Subfolder\MyPDF_File.pdf"

doc.PrintOut False, , , sTempFile
oDistiller.FileToPDF sTempFile, sMyPDF_File, "Print"

Krgrds,
Perry

"Mike Starr"  wrote in message 
news:%23nzqnVF7FHA.3388@TK2MSFTNGP11.phx.gbl...
>I posted this the over in microsoft.public.word.vba.general but didn't
> get what I needed so I thought I'd try here. The answer I got over there
> was unworkable because I don't have access to the users' computers
> to configure their PDF conversion settings.
> 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  -  mike@writestarr.com  -  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  -  mike@writestarr.com  -  http://www.writestarr.com
>
date: Thu, 1 Dec 2005 19:13:09 -0800   author:   Default User

Re: PDF four versions of a document then delete interim saved Word files   
Thanks, Perry

You've pointed me in the direction of something I was completely unaware of 
but it gives me something to work with.

Mike
"Default User"  wrote in message 
news:uByjkLq9FHA.740@TK2MSFTNGP11.phx.gbl...
> Do it in VBA code, setting a pointer in VBE to the Acrobat Distiller 
> library.
> Once the reference to this libary is set, you can use something similar to
> below pseudo code to generate a PDF file in whatever location.
> (note: set a reference to Scripting Runtime library for below code as 
> well)
>
> Dim oDistiller As New PdfDistiller
> Dim fso As New FileSystemObject
> Dim sTempFile As String
> Dim sMyPDF_File As String
>
>
> sTempFile = "c:\temp\" & fso.GetTempName()
> sMyPDF_File = "Z:\Data\a\Abraham\Subfolder\MyPDF_File.pdf"
>
> doc.PrintOut False, , , sTempFile
> oDistiller.FileToPDF sTempFile, sMyPDF_File, "Print"
>
> Krgrds,
> Perry
>
> "Mike Starr"  wrote in message 
> news:%23nzqnVF7FHA.3388@TK2MSFTNGP11.phx.gbl...
>>I posted this the over in microsoft.public.word.vba.general but didn't
>> get what I needed so I thought I'd try here. The answer I got over there
>> was unworkable because I don't have access to the users' computers
>> to configure their PDF conversion settings.
>> 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  -  mike@writestarr.com  -  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  -  mike@writestarr.com  -  http://www.writestarr.com
>>
>
date: Wed, 7 Dec 2005 22:58:04 -0600   author:   Mike Starr

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us