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
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