PowerPoint文件转图像脚本(ppt2img)
作者:佚名 文章来源:51windows.Net 更新时间
:2007-5-30 15:26:48
使用方法:将代码保存为ppt2img.vbs,然后将文件放在sendto文件夹(开始菜单=》选行中输入sendto可以打开)中,然后在ppt文件上点右键,发送到,ppt2img.vbs中,输入要输出图像的格式,然后输入图像的宽与高,脚本会生成一个同名的文件,里面为生成的图像文件。
操作环境:安装Powerpoint程序的window操作系统。
'/////////////////////////////
'/PowerPoint文件转图像脚本(ppt2img)
'/作者:www.51windows.net,海娃
'/使用方法:将此文件放在sendto文件中,然后在ppt文件上点右键,发送到,ppt2img.vbs中,输入要输出图像的格式,然后输入图像的宽与高,脚本会生成一个同名的文件,里面为生成的图像文件。
'/机器上要安装Powerpoint程序
'/////////////////////////////
'on error resume next
Set ArgObj = WScript.Arguments
pptfilepath = ArgObj(0)
imgType = InputBox("输入导出文件的格式,可以是jpg,png,bmp,gif","输入导出文件的格式","png")
if imgType = "" or (lcase(imgType)<>"jpg" and lcase(imgType)<>"png" and lcase(imgType)<>"bmp" and lcase(imgType)<>"gif") then
imgType = "png"
msgbox "输入不正确,以png格式输出"
end if
imgW = InputBox("输入导出图像的宽度","输入导出图像的宽度","640")
if imgW = "" or isnumeric(imgW)=false then
imgW = 640
msgbox "输入不正确,程序使用默认值:640"
end if
imgH = InputBox("输入导出图像的高度","输入导出图像的高度","480")
if imgH = "" or isnumeric(imgH)=false then
imgH = imgW*0.75
msgbox "输入不正确,程序使用默认值:"&imgH
end if
call Form_Load(pptfilepath,imgType)
Private Sub Form_Load(Filepath,format)
if format = "" then
format = "gif"
end if
Folderpath = left(Filepath,len(Filepath)-4)
if lcase(right(Filepath,4))<>".ppt" then
call ConvertPPT(Filepath,Folderpath&".ppt")
end if
Filepath = Folderpath&".ppt"
CreateFolder(Folderpath)
Set ppApp = CreateObject("PowerPoint.Application")
Set ppPresentations = ppApp.Presentations
Set ppPres = ppPresentations.Open(Filepath, -1, 0, 0)
Set ppSlides = ppPres.Slides
For i = 1 To ppSlides.Count
iname = "000000"&i
iname = right(iname,4)'取四位数
Call ppSlides.Item(i).Export(Folderpath&"\"&iname&"."&format, format, imgW, imgH)
Next
Set ppApp = Nothing
Set ppPres = Nothing
End Sub
Function CreateFolder(Filepath)
Dim fso, f
on error resume next
Set fso = CreateObject("Scripting.FileSystemObject")
if not fso.FolderExists(Filepath) then
Set f = fso.CreateFolder(Filepath)
end if
CreateFolder = f.Path
set fso = Nothing
set f = Nothing
End Function
Sub ConvertPPT(FileName1, FileName2)
Dim PPT
Dim Pres
Set PPT = CreateObject("PowerPoint.Application")
Set Pres = PPT.Presentations.Open(FileName1, False, False, False)
Pres.SaveAs FileName2, , True
Pres.Close
PPT.Quit
Set Pres = Nothing
Set PPT = Nothing
End Sub
【相关文章:】
Windows快捷键大全
Windows右键菜单大揭密
Windows内置的事件查看器可解决系统故障
Windows XP 自带小工具
了解你的windows目录和系统文件
讲解Windows XP无人值守自动安装
windows非法操作详解
Windows XP系统注册表解释
ndows Server 2003 VLK在线升级破解
激活您的Windows XP SP2
【发表评论】【打印此文】【关闭窗口】【点击数: 】
操作环境:安装Powerpoint程序的window操作系统。
'/////////////////////////////
'/PowerPoint文件转图像脚本(ppt2img)
'/作者:www.51windows.net,海娃
'/使用方法:将此文件放在sendto文件中,然后在ppt文件上点右键,发送到,ppt2img.vbs中,输入要输出图像的格式,然后输入图像的宽与高,脚本会生成一个同名的文件,里面为生成的图像文件。
'/机器上要安装Powerpoint程序
'/////////////////////////////
'on error resume next
Set ArgObj = WScript.Arguments
pptfilepath = ArgObj(0)
imgType = InputBox("输入导出文件的格式,可以是jpg,png,bmp,gif","输入导出文件的格式","png")
if imgType = "" or (lcase(imgType)<>"jpg" and lcase(imgType)<>"png" and lcase(imgType)<>"bmp" and lcase(imgType)<>"gif") then
imgType = "png"
msgbox "输入不正确,以png格式输出"
end if
imgW = InputBox("输入导出图像的宽度","输入导出图像的宽度","640")
if imgW = "" or isnumeric(imgW)=false then
imgW = 640
msgbox "输入不正确,程序使用默认值:640"
end if
imgH = InputBox("输入导出图像的高度","输入导出图像的高度","480")
if imgH = "" or isnumeric(imgH)=false then
imgH = imgW*0.75
msgbox "输入不正确,程序使用默认值:"&imgH
end if
call Form_Load(pptfilepath,imgType)
Private Sub Form_Load(Filepath,format)
if format = "" then
format = "gif"
end if
Folderpath = left(Filepath,len(Filepath)-4)
if lcase(right(Filepath,4))<>".ppt" then
call ConvertPPT(Filepath,Folderpath&".ppt")
end if
Filepath = Folderpath&".ppt"
CreateFolder(Folderpath)
Set ppApp = CreateObject("PowerPoint.Application")
Set ppPresentations = ppApp.Presentations
Set ppPres = ppPresentations.Open(Filepath, -1, 0, 0)
Set ppSlides = ppPres.Slides
For i = 1 To ppSlides.Count
iname = "000000"&i
iname = right(iname,4)'取四位数
Call ppSlides.Item(i).Export(Folderpath&"\"&iname&"."&format, format, imgW, imgH)
Next
Set ppApp = Nothing
Set ppPres = Nothing
End Sub
Function CreateFolder(Filepath)
Dim fso, f
on error resume next
Set fso = CreateObject("Scripting.FileSystemObject")
if not fso.FolderExists(Filepath) then
Set f = fso.CreateFolder(Filepath)
end if
CreateFolder = f.Path
set fso = Nothing
set f = Nothing
End Function
Sub ConvertPPT(FileName1, FileName2)
Dim PPT
Dim Pres
Set PPT = CreateObject("PowerPoint.Application")
Set Pres = PPT.Presentations.Open(FileName1, False, False, False)
Pres.SaveAs FileName2, , True
Pres.Close
PPT.Quit
Set Pres = Nothing
Set PPT = Nothing
End Sub
【相关文章:】
Windows快捷键大全
Windows右键菜单大揭密
Windows内置的事件查看器可解决系统故障
Windows XP 自带小工具
了解你的windows目录和系统文件
讲解Windows XP无人值守自动安装
windows非法操作详解
Windows XP系统注册表解释
ndows Server 2003 VLK在线升级破解
激活您的Windows XP SP2
【发表评论】【打印此文】【关闭窗口】【点击数: 】
★好玩的休闲小游戏★
网友评论:
数据载入中,请稍后……
