![]() ![]() LcCmd = folGS.ShortPath & "\GSWIN32C.EXE " & _ Set folGS = fso.GetFolder(DanBSolutionsLocation & "Misc\GhostScript\") 'S:\DanB Solutions\Misc\GhostScript\GSWIN32C.EXE If fso.FileExists(svPDFName) Then Call fso.DeleteFile(svPDFName) If DanBSolutionsLocation = "" Then DanBSolutionsLocation = GetDanBSolutionsLocation If svPsFileName = "" Or svPDFName = "" ThenĬall MsgBox("PS file name or PDF file name is blank in ""ConvertToPDF"" macro", vbExclamation, "Error! Missing Inputs")Ĭall MsgBox(svPsFileName & " file is not found", vbExclamation, "Error! Missing File") 'Dim Fso: Set Fso = CreateObject("Scripting.FileSystemObject") Sub ConvertToPDF(ByVal svPsFileName As String, ByVal svPDFName As String) Worksheets(1).PrintOut ActivePrinter:=PSPrinterName, PrintToFile:=True, _Ĭall ConvertToPDF(svPsFileName, svPDFName) ![]() 'If Fso.FileExists(svPsFileName) Then Call Fso.DeleteFile(svPsFileName) 'be sure to install the PsPrinterInstall module ![]() So between the VB.net above and this below hopefully you can salvage something useful. PSPathFileList.ForEach(AddressOf DeleteFiles) 'wait for finish (no more than 60 seconds) 'write file names to text file as the list can be very longĭim tempPath As String = IO.Path.GetDirectoryName(PSPathFileList.Item(0))ĭim fiName2 As String = tempPath & IO.Path.GetFileNameWithoutExtension(PDFPathName) & ".txt"įt.WriteLine("-sDEVICE=pdfwrite -q -dSAFER -dNOPAUSE -sOUTPUTFILE=""" & PDFPathName & """ -dBATCH ")įor i As Long = 0 To PSPathFileList.Count - 1įt.WriteLine(Chr(34) & PSPathFileList.Item(i) & Chr(34))ĭim myProc As Process = Process.Start(myProcInfo)ĭebug.Print()ĭebug.Print() MyProcInfo.FileName = DanBSolutionsLocation & "Misc\GhostScript\GSWIN32C.EXE" PSPathFileList.ForEach(AddressOf CheckFiles) Private Shared Sub ConvertToPDF(ByVal PSPathFileList As List(Of String), _īyVal WaitForExit As Boolean, ByVal DeletePS As Boolean) Basically you write the options and file names to a text file then use that file as an argument to Ghostscript. But it illustrates the concept if you can wade through it. ![]() Sorry it's in VB.net and I don't really have time to convert. This uses a list of PDF or PS files to create one PDF. ObjCAcroPDDocDestination.save 1, strSaveAs 'Save it as a new name If objCAcroPDDocDestination.InsertPages(objCAcroPDDocDestination.GetNumPages - 1, objCAcroPDDocSource, 0, objCAcroPDDocSource.GetNumPages, 0) Then 'Open the source document that will be added to the destinationįor i = LBound(arrFiles) + 1 To UBound(arrFiles) 'Open each subsequent PDF that you want to add to the original ObjCAcroPDDocDestination.Open (arrFiles(LBound(arrFiles))) 'open the first file 'Open Destination, all other documents will be added to this and saved with Set objCAcroPDDocSource = CreateObject("AcroExch.PDDoc") Set objCAcroPDDocDestination = CreateObject("AcroExch.PDDoc") Public Function MergePDFs(arrFiles() As String, strSaveAs As String) As Booleanĭim objCAcroPDDocDestination As Acrobat.CAcroPDDocĭim objCAcroPDDocSource As Acrobat.CAcroPDDoc If bSuccess = False Then MsgBox "Failed to combine all PDFs", vbCritical, "Failed to Merge PDFs"ĭoCmd.RunSQL "delete from scantemp" 'delete all paths from table scantemp after converted it to pdf StrNPDF = CurrentProject.Path & "\request_pic\" & (request_no) & ".pdf" Set RS = DB.OpenRecordset("SELECT from scantemp ") Notice:-the number of pdfs files to be merged varies from time to time. I have a table that contains a paths of multi pdfs file.now I need a VBA code to merge all these files to a single pdf file. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |