Hi!
I am looking for a way in VBA I can print using the CutePDF printer to a predefined folder. I can make the code that is printed, and luckily the name well, only remains the folder in the folder where a previous PDF is printed.
' Print_to_PDF ' Dim myFileName As String Dim myOriginalFileNameForSaving As Variant myFileName = ActiveWorkbook.Name myOriginalFileNameForSaving = Replace(myFileName, ".csv", "") ' Range("A1:I47").Select ActiveSheet.PageSetup.PrintArea = "$A$1:$I$47" Application.ActivePrinter = "CutePDF Writer op CPW2:" ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _ "CutePDF Writer op CPW2:", Collate:=True Filename = myOriginalFileNameForSaving Range("A1").Select
I think I just need a way to indicate where the file should be saved. I thought to do that with this line:
File Name = myOriginalFileNameForSaving
But apparently it does not. Is it possible to make something to do this? Or is it build in CutePDF and not possible to edit?
Kind regards,
Brigitte
I found something on http://www.codeproject.com/answers/4...F-CutePDF.aspx
It concerns the following line:
HKLM \ Software \ Acro Software Inc \ CPW \ File Name
And I found this, (at http://www.cutepdf.com/Solutions/pdfwriter3.asp):
Private Sub Print_PDF() Dim lRetVal As Long Dim hKey As Long Dim sValue As String lRetVal = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\Custom PDF Printer", _ 0&, vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, _ 0&, hKey, lRetVal) sValue = "C:\Sample.pdf" RegSetValueExString hKey, "OutputFile", 0&, REG_SZ, sValue, Len(sValue) sValue = "1" RegSetValueExString hKey, "BypassSaveAs", 0&, REG_SZ, sValue, Len(sValue) Dim worddoc As Word.Document Set worddoc = wordapp.Documents.Open("C:\Sample.doc") wordapp.ActivePrinter = "Custom PDF Printer" wordapp.PrintOut worddoc.Close sValue = "0" RegSetValueExString hKey, "BypassSaveAs", 0&, REG_SZ, sValue, Len(sValue) RegCloseKey (hKey) End Sub
I understand its written for Microsoft Word, but I'm not good enough in this language to understand what line is telling where to put the new PDF-file... I think it would be (almost) the same for excel.
It is written in visual basic, but maybe this can help someone to send them in the right direction, to find anything in VBA? I still look around and try, but I'm afraid that I can't think any solution ...
Hopefully you are able to give me a nudge in the right direction?
Best regards,
Brigitte
Last edited by Brie; 02-17-2010 at 08:00 AM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks