我有一些出類拔萃,我刷新夜間打開Excel,並通過文件密碼通過
我現在想用密碼保護它們,以從中修改任何數據文件,但是當腳本打開文件時,它會提示輸入密碼,
我如何傳遞密碼與腳本?
繼承人我使用(嘗試)
Set fs = CreateObject("Scripting.FileSystemObject")
Set rootFolder = fs.GetFolder(fs.GetParentFolderName(wscript.ScriptFullName))
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
oExcel.DisplayAlerts = False
oExcel.AskToUpdateLinks = False
oExcel.AlertBeforeOverwriting = False
For Each file in rootFolder.Files
If inStr(file.type, "Script") = 0 Then
Set oWorkbook = oExcel.Workbooks.Open(file.path)
Dim WSH
Set WSH = CreateObject("WScript.Shell")
wsh.sleep(25000)
Wsh.SendKeys "?"
Wsh.SendKeys "{ENTER}"
oWorkbook.RefreshAll
oWorkbook.Save
oWorkbook.Close
Set oWorkbook = Nothing
End If
Next
oExcel.Quit
set oExcel = nothing
任何幫助嗎?我沒有真正使用vbs很多(根本沒有)
編輯,此代碼在打開文件的工作刷新所有,保存然後關閉,我只是不知道如何得到它輸入密碼以便全面打開它編輯模式
Set fs = CreateObject("Scripting.FileSystemObject")
Set rootFolder = fs.GetFolder(fs.GetParentFolderName(wscript.ScriptFullName))
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
oExcel.DisplayAlerts = False
oExcel.AskToUpdateLinks = False
oExcel.AlertBeforeOverwriting = False
For Each file in rootFolder.Files
If inStr(file.type, "Script") = 0 Then
Set oWorkbook = oExcel.Workbooks.Open(file.Path)
oWorkbook.RefreshAll
oWorkbook.Save
oWorkbook.Close
Set oWorkbook = Nothing
End If
Next
oExcel.Quit
set oExcel = nothing
它沒有工作,讓 – lookslikeanevo 2014-12-05 20:20:01
@lookslikeanevo「語句的預期結束」的錯誤 - apols,錯過了括號,回答編輯 – barryleajo 2014-12-05 20:30:39
現在變得「預期」)'「 – lookslikeanevo 2014-12-05 20:38:02