Thread: password in VBA
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default password in VBA

Search VBA's help for "Open Method"
Then open the link for "Open method as it applies to the Workbooks object."

You'll see how you can pass parms to the .open statement:

expression.Open(FileName, UpdateLinks, ReadOnly, Format, Password,
WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter, Editable,
Notify, Converter, AddToMru, Local, CorruptLoad)

So just like you passed an option (the updatelinks stuff), you can use:

Workbooks.Open Filename:= _
"\\Admin-hdd\budget-contr\BUDGET CONTROL M\BUDGET 2009\M10-9-006 ASAHI.xlsx", _
UpdateLinks:=0, password:="topsecretpassword"



Frank Situmorang wrote:

Hello,

I am trying to understand how macro will write the password in VBAmby using
recording Macro for a protected password workbooks, because I am trying to
make a link base on the example 1 of Mr. Ron De Bruin, but I can not see the
VBA of the password itself:

Here is the VBA of my recording:
Sub testh()
'
' testh Macro
' Ini adalah untuk mengetest kalau pakai password
'
' Keyboard Shortcut: Ctrl+Shift+H
'
ChDir "\\Admin-hdd\budget-contr\BUDGET CONTROL M\BUDGET 2009"
Workbooks.Open Filename:= _
"\\Admin-hdd\budget-contr\BUDGET CONTROL M\BUDGET 2009\M10-9-006
ASAHI.xlsx", _
UpdateLinks:=0
End Sub

Thanks for any help.

Frank


--

Dave Peterson