Change destinationsfolder [Solved]

XL-Dennis

Well-known Member
Joined
Jul 27, 2002
Messages
1,920
Hi Board,

I hade a problem with saving created PDF-files to the activeworkbooks folder.

Finally I could solve it myself :) :)

For thos who´s interested here is the final solution (need to add a check if activeworkbook is saved or not):<PRE><FONT color=blue>Sub</FONT>Convert_XLS_PDF()<FONT color=blue>Dim</FONT>stFileName<FONT color=blue> As</FONT><FONT color=blue> String</FONT><FONT color=blue>Dim</FONT>stFilePath<FONT color=blue> As</FONT><FONT color=blue> String</FONT><FONT color=blue>Dim</FONT>stActivePath<FONT color=blue> As</FONT><FONT color=blue> String</FONT><FONT color=blue>Dim</FONT>stActivePrinter<FONT color=blue> As</FONT><FONT color=blue> String</FONT><FONT color=blue>Dim</FONT>stTitle<FONT color=blue> As</FONT><FONT color=blue> String</FONT><FONT color=blue>Dim</FONT>objDistiller<FONT color=blue> As</FONT><FONT color=blue> New</FONT>ACRODISTXLib.PdfDistiller



stTitle = "Konvertera Excel-filer till PDF-dokument"

stFileName = ActiveWorkbook.Name

stFileName = Left(stFileName, Len(stFileName) - 3)

stFilePath = ActiveWorkbook.Path

stActivePrinter = Application.ActivePrinter<FONT color=blue>On Error</FONT><FONT color=blue>GoTo</FONT> Errorhandling

Application.ActivePrinter = "Acrobat Distiller på Ne01:"



ActiveSheet.PrintOut PrToFilename:=stFilePath & "" & stFileName & "ps"



objDistiller.FileToPDF stFilePath & "" & stFileName & "ps", stFilePath & "" & stFileName & "pdf", ""



Kill stFilePath & "" & stFileName & "ps"



Application.ActivePrinter = stActivePrinter<FONT color=blue>Set</FONT>objDistiller =<FONT color=blue> Nothing</FONT><FONT color=blue>Exit Sub</FONT>



Errorhandling:<FONT color=blue>If</FONT>Err.Number = 1004 Then

MsgBox "Antingen avbröts utskriften eller så inträffade ett allvarligt fel.", vbInformation, stTitle<FONT color=blue>Else</FONT>

MsgBox "Acrobat Distiller är ej installerad.", vbInformation, stTitle<FONT color=blue>End If</FONT><FONT color=blue>Exit Sub</FONT><FONT color=blue>End Sub</FONT></PRE>


Kind regards,
Dennis
This message was edited by XL-Dennis on 2002-08-22 03:00
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,214,870
Messages
6,122,021
Members
449,060
Latest member
LinusJE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top