vbscript - Open Excel and pass file password through -


i have excel files refresh nightly

i want password protect them in order modify data them, when script opens file prompts password,

how pass password script?

heres use(have tried)

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   each file in rootfolder.files    if instr(file.type, "script") = 0      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 

any help? dont use vbs much(at all)

edit, code works in opening file refreshing all, saving closing, dont know how input pass word in order open in full edit mode

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    each file in rootfolder.files    if instr(file.type, "script") = 0      set oworkbook = oexcel.workbooks.open(file.path)       oworkbook.refreshall      oworkbook.save      oworkbook.close      set oworkbook = nothing   end if  next   oexcel.quit set oexcel = nothing 

it wasn't clear me in addition advice @wahwahwah here other interpretation:

set oworkbook = oexcel.workbooks.open(filename:=file.path, password:="<mypassword") 

edit

set oworkbook = oexcel.workbooks.open(filename:=filepath, password:="<mypassword") 

edit 2

further discussion , clarification identified syntax in vbscript seemed work!

set oworkbook = oexcel.workbooks.open(file.path,,,, "mypassword",,,,,,,,,,) parameters suit.

this link gave inspiration!

msdn.microsoft.com/en-us/…


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -