01.
<JOB>
02.
<OBJECT id=
"Fso"
progid=
"Scripting.FileSystemObject"
/>
03.
<OBJECT id=
"ExcelApp"
progid=
"Excel.Application"
/>
04.
<REFERENCE guid=
"00020813-0000-0000-C000-000000000046"
/>
05.
<SCRIPT language=
"VBScript"
>
06.
07.
08.
09.
10.
11.
strCurPath = WScript.ScriptFullName
12.
Set
obj = Fso.GetFile( strCurPath )
13.
Set
obj = obj.ParentFolder
14.
strCurPath = obj.Path
15.
16.
17.
18.
19.
ExcelApp.Visible =
True
20.
21.
Dim
MyBook
22.
Dim
FilePath
23.
24.
25.
FilePath = ExcelApp.GetOpenFilename(
"Excel ファイル (*.xlsx;*.xls), *.xlsx;*.xls"
, 1,
"Excel ファイルの選択"
)
26.
if FilePath =
"False"
Then
27.
MsgBox
"Excel ファイルの選択がキャンセルされました"
28.
29.
Wscript.Quit()
30.
End
If
31.
32.
33.
on error resume next
34.
35.
Set
MyBook = ExcelApp.Workbooks.Open( FilePath )
36.
if Err.Number <> 0 then
37.
38.
ExcelApp.Quit()
39.
Wscript.Echo Err.Description & vbCrLf & FilePath
40.
41.
Wscript.Quit()
42.
end if
43.
on error goto 0
44.
45.
Dim
aPath
46.
Dim
strFileName
47.
Dim
aExt
48.
49.
50.
aPath = Split(FilePath,
"\"
)
51.
strFileName = aPath(Ubound(aPath))
52.
aExt = Split(strFileName,
"."
)
53.
strFileName = aExt(0)
54.
55.
56.
Call
MyBook.ExportAsFixedFormat( xlTypePDF, strCurPath &
"\" & strFileName & "
.pdf" )
57.
58.
59.
ExcelApp.Quit()
60.
61.
62.
Wscript.Echo
"処理が終了しました"
63.
64.
</SCRIPT>
65.
</JOB>