・インストールは、
1.後述するスクリプトのコードを、テキストエディタ等で拡張子を vbs にして保存します。
(ここでは、ファイル名を ImpressViewer.vbs と保存した事にします)
・使い方は、
1.プレゼンテーションを行いたいファイルを ImpressViewer.vbs のアイコンにドロップします。
(複数のファイルを同時にドロップした場合は(フォルダ名含)ファイル名順にプレゼンテーションします)
( odp ファイルと ppt ファイルを混在させた場合でも同様です)
(プレゼンテーション以外のファイルの場合は、単純に OpenOffice で開きます)
(存在しないファイル名は無視します)
2.プレゼンテーションが終われば( ImpressViewer.vbs が) Impress も終了させます。
・[送る]フォルダにショートカットを登録すれば簡単に利用出来ると思います。
([送る]フォルダは、C:\Documents and Settings\%UserName%\SendTo です)
ImpressViewer.vbs です。
コード: 全て選択
set args = WScript.Arguments
if args.Count < 1 then WScript.Quit
set oServiceManager = CreateObject("com.sun.star.ServiceManager")
set oDesktop = oServiceManager.createInstance("com.sun.star.frame.Desktop")
' ファイル名順に並べ替えます(単純なバブルソートです)
redim aIndex(args.Count - 1)
for i = 0 to UBound(aIndex)
aIndex(i) = i
next
for i = UBound(aIndex) to 1 step -1
for j = 1 to i
if args.item(aIndex(j - 1)) > args.item(aIndex(j)) then
temp = aIndex(j)
aIndex(j) = aIndex(j - 1)
aIndex(j - 1) = temp
end if
next
next
' 設定値を指定します
dim aLoadProperty(0)
set aLoadProperty(0) = oServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
aLoadProperty(0).Name = "Hidden"
aLoadProperty(0).Value = true
dim aStartProperty(2)
set aStartProperty(0) = oServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
aStartProperty(0).Name = "IsAlwaysOnTop"
aStartProperty(0).Value = true
set aStartProperty(1) = oServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
aStartProperty(1).Name = "IsFullScreen"
aStartProperty(1).Value = true
set aStartProperty(2) = oServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
aStartProperty(2).Name = "AllowAnimations"
aStartProperty(2).Value = true
bFrameRecycle = false
' ファイル数繰り返します
for i = 0 to UBound(aIndex)
' ファイルを開きます
set oDoc = Nothing
on error resume next
if bFrameRecycle then
set oDoc = oFrame.loadComponentFromURL("file:///" + args.item(aIndex(i)), "_self", 2, aLoadProperty)
else
set oDoc = oDesktop.loadComponentFromURL("file:///" + args.item(aIndex(i)), "_blank", 0, aLoadProperty)
set oFrame = oDoc.CurrentController.Frame
end if
on error goto 0
if not oDoc is Nothing then
' ドキュメントが、プレゼンテーションではない場合は表示させて放置します
if not oDoc.supportsService("com.sun.star.presentation.PresentationDocument") then
call oFrame.ContainerWindow.setVisible(true)
bFrameRecycle = false
else
' 非表示のままだとクラッシュしてしまうので、一瞬表示させます
call oFrame.ContainerWindow.setPosSize(0, 0, 0, 0, 15)
oFrame.ContainerWindow.IsMinimized = true
call oFrame.ContainerWindow.setVisible(true)
call oFrame.ContainerWindow.setVisible(false)
' プレゼンテーションを開始して終了まで待ちます
call oDoc.Presentation.startWithArguments(aStartProperty)
while oDoc.Presentation.isRunning
call wscript.sleep(1000)
wend
bFrameRecycle = true
end if
end if
next
' ドキュメントを閉じて終了します
if bFrameRecycle then
if oDesktop.Frames.Count > 1 then
call oFrame.close(true)
else
call oDesktop.terminate
end if
end if