Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Input Password to Open Linked Files

2 views
Skip to first unread message

Ricky Pang

unread,
Jul 30, 2003, 6:58:21 PM7/30/03
to
Hello Experts,
How do you write a code that will input the password to open the linked
file as the "Master file" tries to update?
For example:
1) While opening my "Master file", the prompt to Update linked files
pops up. If "Yes" is selected, then input the password "openA" to open
the linked file (File A).
2) On the next linked file (File B), input password "openB"

3) While opening my Master file, if Update linked files "No" is
selected, then end.

Your help is greatly appreciated.

Ricky

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Dave Peterson

unread,
Jul 31, 2003, 12:29:00 AM7/31/03
to
If you're writing code, then you're opening the workbooks via code, too???

(seems reasonable to me.)

Take another look at workbooks.open in VBA's help. You can specify the password
on that command.

--

Dave Peterson
ec3...@msn.com

Ricky Pang

unread,
Aug 1, 2003, 1:23:18 AM8/1/03
to
Hi Dave,
To clarify, I wanted to input the password (using code) when the update
linked file prompt pops up. My linked file has a password on it before
it can be assessed, but I don't need to open that linked file though.
Just want to go through the prompts, input the password, so my Master
file can be updated. Any ideas?

Thanks,

Dave Peterson

unread,
Aug 1, 2003, 10:41:56 PM8/1/03
to
Ahhh. I get it now.

But I looked through the help for linksources and updatelink and didn't find
anything that looked like it accepted a password.

The closest thing I could come up with is using Sendkeys and if you're unlucky
enough to not be in the right spot, lots of bad things could happen. (Sendkeys
doesn't care what application is active--it doesn't care about anything. It
just sends them just like you typed the characters.)

I created one workbook with one link to a workbook that was password protected.

Option Explicit

Sub testme()

Dim wkbk As Workbook
Dim myLinks As Variant
Dim iCtr As Long

Set wkbk = Workbooks.Open(Filename:="book1.xls", UpdateLinks:=False)

With wkbk
myLinks = .LinkSources
If IsArray(myLinks) Then
For iCtr = LBound(myLinks) To UBound(myLinks)
SendKeys "a{enter}"
wkbk.UpdateLink myLinks(iCtr)
Next iCtr
Else
MsgBox "no links found!"
End If
End With

End Sub

You could keep track of passwords and links and send the right password when you
need to.

If this were something I was sharing with others, I wouldn't use it.

But if it was just for me, I think I might use it and know to not do anything
when the code was running.

I hope that I could fix anything that broke when sendkeys works perfectly, but
doesn't do what I want.

(Nah, I wouldn't use it.)

--

Dave Peterson
ec3...@msn.com

Ricky Pang

unread,
Aug 1, 2003, 11:55:44 PM8/1/03
to
Hi Dave,
Thanks for the warning. I have heard about the danger associated with
sendkeys and you are right... Sometimes a little manual input sure beats
the heartache that comes along when the sendkeys go awry.

Much appreciated,

0 new messages