Linking To Password Protected Worksheeets

Gettingbetter

Well-known Member
Joined
Oct 12, 2004
Messages
602
Hi Everyone

I have searched and searched for an answer to this but can not find one.

I run a macro that inserts links into cells,

What I need is, when linking to a spreadsheet that is password protected you get prompted for the password. Is there any way you can add the password to your code so that the user does not have to keep putting in the password.

I am hoping I do not have to open the spreadsheets im linking to as there big.

Cheers
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
try opening the workbook by means of code, then place the links, and after close it. I'm not sure if you can close it though, but i hope so :LOL:
 
Upvote 0
This worked for me:

Code:
Sub Test()
    Const PWord As String = " "
    SendKeys PWord & "{Enter}"
    ActiveCell.Formula = _
        "='P:\TEMP\MrExcel\FileLinksPWord\[Source.xls]Sheet1'!A1"
End Sub

The password for Source.xls was a single space. Change the constant PWord to suit.
 
Upvote 0
Andrew you are a superstar

The sendkeys works perfectly...

Just another little thing... If the spreadsheet is open then the sendkeys obviously is not needed.. Do you know a variation of the below code that works so that I can make it miss sendkeys if the workbook is open

'this code does not work
if Workbooks.Open Filename:= _
"C:\password.xls" = true then exit sub

I have tried loads of combinations but cant get it to work

Cheers
 
Upvote 0
Code:
for each w in workbooks
  if w.name = myWorkbookname then isitopen = true
next w
 
Upvote 0

Forum statistics

Threads
1,214,824
Messages
6,121,784
Members
449,049
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top