Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 08-31-2009, 04:46 PM   #1
Solid State Member
Join Date: Jun 2004
Posts: 11
Default macro that creat a PDF on a specific folder

Hi everyone,
I am runing windows XP pro woth Office 2002 and Acrobat writer 5
I am trying to write a macro that will create a PDF on a specific Driver\folder\name.pdf

this is what I have :
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"Acrobat distiller:", Collate:=True

newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 2
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
Filename = "G:\Temp\Seth-quotes" & ActiveSheet.Range("a13").Value
SendKeys Filename & "{ENTER}", False

I print it on paper first and then I want to printer as a PDF and it kind of works but it gives me the screen where it ask me where to save the file.. so I know that the part on red doesn't work on the script.

I want to create two button that will create from a set area a pdf and save it on G:\folder1\filename.pdf
and the other button that same the same area into a file on G:\folder2\filename.pdf

Does anyone have any idea of how to do that.


I got this code that works but I have to have Acrobat Distiller as a default printer. What I need to do is print a hard copy and create a PDF on a specific folder automatically. but with this code I can only print a PDF to specific file and no print out. the code is as follow:

Dim PSFileName As String
Dim PDFFileName As String
PSFileName = "G:\Temp\Purvis-quotes\" & ActiveSheet.Range("A13").Value & ".ps"
PDFFileName = "G:\Temp\Purvis-quotes\" & ActiveSheet.Range("A13").Value & ".pdf"

'Print the Excel range to the postscript file
ActiveWindow.SelectedSheets.PrintOut Copies:=1, preview:=False, ActivePrinter:="Adobe distiller on Ne11", _
printtofile:=True, Collate:=True, prtofilename:=PSFileName

'Convert the postscript file to .pdf
Dim myPDF As PdfDistiller
Set myPDF = New PdfDistiller
myPDF.FileToPDF PSFileName, PDFFileName, ""

Does anyone know how can i also print a hard copy or how to create a PDF without having to change the printers defaults

Access2mex is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 08:07 AM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0