VBSCRIPT 保存
VBSCRIPT SAVEAS
我有以下内容:
set wshshell=createobject("wscript.shell")
wshshell.run """C:\ReportName.pdf"""
这将打开指定的 PDF。我需要什么代码才能将打开的文件另存为,例如另存为...将其另存为相同的文件名?
谢谢
这里是示例代码
set wshshell=createobject("wscript.shell")
wshshell.run """C:\ReportName.pdf"""
wscript.sleep 2000 'sleep for 2 seconds to ensure file is open
wshshell.SendKeys "%{F}{A}" 'simulate ALT+F+A to open SaveAs dialog
wscript.sleep 5000 ' sleep for 5 seconds so that the save as dialog is open
wshshell.SendKeys "+{TAB}{ENTER}" 'simulate Shit+Tab so that the tab is moved backed to Choose a diff folder option
wscript.sleep 2000
wshshell.SendKeys "C:\NewFile.PDF{ENTER}"
wscript.sleep 3000
wshshell.SendKeys "%{F}{X}"
听起来您想复制文件或 move/rename 文件。如果是这样,请使用 FileSystemObject
:
Set fso = CreateObject("Scripting.FileSystemObject")
Call fso.CopyFile("C:\ReportName.pdf", "C:\NewReport.pdf")
' or
Call fso.MoveFile("C:\ReportName.pdf", "C:\NewReport.pdf")
我有以下内容:
set wshshell=createobject("wscript.shell")
wshshell.run """C:\ReportName.pdf"""
这将打开指定的 PDF。我需要什么代码才能将打开的文件另存为,例如另存为...将其另存为相同的文件名?
谢谢
这里是示例代码
set wshshell=createobject("wscript.shell")
wshshell.run """C:\ReportName.pdf"""
wscript.sleep 2000 'sleep for 2 seconds to ensure file is open
wshshell.SendKeys "%{F}{A}" 'simulate ALT+F+A to open SaveAs dialog
wscript.sleep 5000 ' sleep for 5 seconds so that the save as dialog is open
wshshell.SendKeys "+{TAB}{ENTER}" 'simulate Shit+Tab so that the tab is moved backed to Choose a diff folder option
wscript.sleep 2000
wshshell.SendKeys "C:\NewFile.PDF{ENTER}"
wscript.sleep 3000
wshshell.SendKeys "%{F}{X}"
听起来您想复制文件或 move/rename 文件。如果是这样,请使用 FileSystemObject
:
Set fso = CreateObject("Scripting.FileSystemObject")
Call fso.CopyFile("C:\ReportName.pdf", "C:\NewReport.pdf")
' or
Call fso.MoveFile("C:\ReportName.pdf", "C:\NewReport.pdf")