I am trying to write an hta that will allow a end user to select multiple pdf documents and then merge them into one document.
I can do it if I let the user select a single file at a time but the multiple file selects is cuasing me a headache. Any suggestions.
Here is what I have so far
bn2hunt
"Born to hunt forced to work
I can do it if I let the user select a single file at a time but the multiple file selects is cuasing me a headache. Any suggestions.
Here is what I have so far
Code:
<html>
<head>
<title>Append PDF files</title>
<HTA:APPLICATION
ID="appendpdf"
APPLICATIONNAME="appendpdf"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="maximize"
>
</head>
<style>
BODY
{
background-color: buttonface;
font-family: Helvetica;
font-size: 8pt;
margin-top: 10px;
margin-left: 20px;
margin-right: 20px;
margin-bottom: 10px;
}
.button
{
font-family: Helvetica;
font-size: 8pt;
width: 130px;
}
textarea
{
font-family: arial;
font-size: 8pt;
}
select
{
font-family: arial;
font-size: 8pt;
width: 800px;
margin-left: 0px;
}
td
{
font-family: arial;
font-size: 10pt;
}
</style>
<body>
<br>
<table border width="100%">
<tr>
<td>
<SCRIPT LANGUAGE="VBScript">
Set ws = CreateObject("WScript.Shell")
Set fs = CreateObject("Scripting.FileSystemObject")
Set doc = CreateObject("CDIntfEx.Document")
Sub window_onload()
argpassed = ws.ExpandEnvironmentStrings ("%ASEEXEARGS%")
If argpassed <> "" Then
MsgBox argpassed
firstfile.value = argpassed
Else
MsgBox "argpassed failed"
End If
h = 230
w = 600
sxTop = window.screen.height/2 -(h/2)
sxLeft = window.screen.width/2 -(w/2)
self.MoveTo sxLeft, sxTop
self.ResizeTo w, h
End Sub
Sub TestSub
If firstfile.value = "" Then
MsgBox "must select the first file to append"
Exit Sub
Else
doc.open firstfile.value
End If
If secfile.value = "" Then
MsgBox "only one file selected, please select a second file"
Exit Sub
Else
doc.append secfile.value
If thirdfile.value = "" Then
lit1 = ws.popup("I am going to append the following file(s)" & vbcr & firstfile.value & vbcr & secfile.value)
Else
DOC.APPEND thirdfile.value
If forthfile.value = "" Then
lit1 = ws.popup("I am going to append the following file(s)" & vbcr & firstfile.value & vbcr & secfile.value & vbcr & thirdfile.value)
Else
DOC.APPEND forthfile.value
End If
End If
End If
lit1 = "Enter a new filename for the combined files" & vbcr
lit1 = lit1 & "It will be saved to your desktop"
filename = InputBox(lit1,"Enter a filename","combined.pdf")
If LCase(Right(filename,4)) <> ".pdf" Then filename = filename & ".pdf"
doc.Save ws.ExpandEnvironmentStrings("%ALLUSERSPROFILE%") & "\desktop\" & filename
End Sub
</SCRIPT>
<body>
<table>
<tr>
<td>First File Name </td>
<td><INPUT type="file" size="40" name="firstfile" </td>
</tr>
<tr>
<td >Second File Name</td>
<td><INPUT size = 40 type="file" name="secfile"</td>
</tr>
<tr>
<td >Third File Name</td>
<td><INPUT size = 40 type="file" name="thirdfile"</td>
</tr>
<tr>
<td >Forth File Name</td>
<td><INPUT size = 40 type="file" name="forthfile"</td>
</tr>
<TR>
<TD><INPUT TYPE=BUTTON NAME="APPEND" Value = "Append PDF Documents" ONCLICK="testsub"</TD>
<td><input type=button name="close" value = "Close" onclick="window.close()"</td>
</TR>
</table>
</body>
</html>
bn2hunt
"Born to hunt forced to work