Hi,
I have been cracking my head all afternoon on how to convert a word file into PDF. After many hours of serarching I got the piece of code below thanks to this site. I twicked it to suite my needs by changing the the file name & path. To cut the long story short, it saves a ".ps" file and then converts it to ".pdf" file.
The above only works if I step through the script with F8. When executed with Run or with a button it gives "The file is used being by another process" error message.
Can anybody advise me on how to resolve the above issue?
[vba]
Dim PSFileName As String
Dim PDFFileName As String
PSFileName = SavedDir & "\" & StrTrimmed & "_" & Format(Date, "ddmmyyyy") & "_" & Format(Time, "mmhhss") & ".ps"
PDFFileName = SavedDir & "\" & StrTrimmed & "_" & Format(Date, "ddmmyyyy") & "_" & Format(Time, "mmhhss") & ".pdf"
' Print the file to the postscript file
Dim MyDoc As Document
Set MySheet = ActiveDocument
' Print out to post script file
MyDoc.PrintOut outputfilename:=PSFileName, copies:=1, ActivePrintermacgx:="Acrobat Distiller", _
printtofile:=True, collate:=True
' Convert the postscript file to .pdf
Dim myPDF As PdfDistiller
Set myPDF = New PdfDistiller
myPDF.FileToPDF PSFileName, PDFFileName, ""
[/vba]
Kind Regards,
ChrisMac