Need help with moving a file & opening up PDF

OS = winXP Pro SP3

First of all, I have a business degree and not a programming degree so please bear with me. I'm sure many of you programming experts could figure this out quickly but I'm faltering badly. Last few years I've dabbled around with VBA and just picked up my first VBA book so I only know snippets of code.

I have some special installed on my computer that allows me to convert any document (including Word files) into PDF. Many times in Word, I'll make changes to my resume and in the Print dialog box that pops up, I choose the Ghost PDF printer and when I click 'Print', the result is a PDF version of my resume located in:

"x:StuffConverted PDFs"

The file name is always thus: "Microsoft Word - {whatever I'm currently editing}.docx.pdf"

e.g.
"x:StuffConverted PDFsMicrosoft Word - John's Resume.docx.pdf"

The software is configurable. I could make it so that converted PDF file kicks out to a different directory, but I wish to keep it as is. changing the configuration (ouput path) is not the most user friendly and there are several steps to jump through. I know there might be better PDF making software available but I've been using this for years and the resulting PDFs looks so sharp that I love using it.

As a VBA newbie, I noticed one day that Adobe Acrobat v7 was listed in the references library. So as a VBA newb, I started to think about how to make VBA interact with Acrobat Reader.

I have put together a very crude attempt to the following:

(I have Office 2007 installed by the way):

[code]Sub Print_PDF()

Dim fso As FileSystemObject
Dim docName As String
Dim Fn_Curr As String
Dim Fn_New As String
Dim Dir_output As String
Dim Dir_Dest As String

Dir_output = "x:Stuff"
Dir_Dest = "x:Resumes2009"
Fn_Curr = "Microsoft Word - " & ActiveDocument.Name & ".pdf"

ActivePrinter = "Ghost PDF Printer"
Application.PrintOut FileName:="", Range:=wdPrintAllDocument
ActiveDocument.Save
---------------------------------------------------------------
Step 2:
Change the PDF file name:
"Microsoft Word - Resume_John[color=Red].docx[/color].pdf" or:

I don't need to know the resume was finished in Word so how do you
trim the file name? delete "Microsoft Word - " and delete .docx from
the file name so it looks like this:

"Resume_John.pdf"

The [color=Red]red portion[/color] is a variable. Sometimes I'll take
old word documents (done in Office 2003) and modify them so the file
extension could also look like: *.doc.pdf

Step 3:
Move the file from the output path (which is a constant) to the a different folder (also a constant).

output: "x:Stuff"
destination: "x:JohnTechnical Resumes"

fso.MoveFile Dir_output & Fn_New ?

Step 4:
Finally, open up the PDF file.

By checking the box listed in the references for Adobe Acrobat, is it
possible to have VBA or VB fire up Acrobat Reader? I like to open up
the PDF file so that I don't have to go to the destination directory
and double click on the PDF file every single time.

Set fso = Nothing
Set docName = Nothing
Set Fn_Curr = Nothing
Set Fn_New = Nothing
Set Dir_output = Nothing
Set Dir_Dest = Nothing

End Sub[/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories