- 精品下载 | 实用查询 | 词典查询 | 桌面壁纸 | 网址 | 笑话 | FLASH频道 | 天气文章资讯 | 站长工具 | 证件办理 | 闪字生成 | 广告代码 | 在线手册 | 有问必答
您现在的位置: 蓝派网 >> 文章中心 >> 网络编程 >> ASP >> 正文
站内文章搜索:           

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
  • 上一篇文章:
  • 下一篇文章:
  • 百度搜索: PowerPoint文件转图像脚本(ppt2img)

  • 发表评论】【打印此文】【关闭窗口】【点击数:
    ★好玩的休闲小游戏★
    网友评论:
    数据载入中,请稍后……