Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

merge pdf files

Status
Not open for further replies.

elly00

Technical User
Jun 30, 2011
69
IT
hi
I've installed the adove writer and with the following script I can merge file saved on a folder..
Now I need to choose the file to merge, may be reading a string that contain all path divided by ; and splitting it..
Do you think is possible?
This is the code:

Set fso = CreateObject("Scripting.FileSystemObject")
sFolder = "M:\test\" 'path dove creare il pdf
Set oFolder = fso.GetFolder(sFolder)
Set oArgs = WScript.Arguments
If oArgs.Count = 0 Then
'Double Click
MergeFiles
End If
'=======================================================
Sub MergeFiles()
bFirstDoc = True
If oFolder.Files.Count < 2 Then
MsgBox "needed 2 pdf."
Exit Sub
End If
For Each oFile In oFolder.Files
If LCase(Right(oFile.Name, 4)) = ".pdf" Then

If bFirstDoc Then
bFirstDoc = False
Set oMainDoc = CreateObject("AcroExch.PDDoc")
oMainDoc.Open sFolder & "\" & oFile.Name
Else
Set oTempDoc = CreateObject("AcroExch.PDDoc")
oTempDoc.Open sFolder & "\" & oFile.Name
oMainDoc.InsertPages oMainDoc.GetNumPages - 1, oTempDoc, 0, oTempDoc.GetNumPages, False
oTempDoc.Close
End If
End If
Next

oMainDoc.Save 1, sFolder & "\Do.pdf"
oMainDoc.Close
MsgBox "ok"
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top