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
 

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Harvey

Well-known Member
Joined
Nov 18, 2004
Messages
953
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:
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
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.
 

Gettingbetter

Well-known Member
Joined
Oct 12, 2004
Messages
602
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
 

Harvey

Well-known Member
Joined
Nov 18, 2004
Messages
953
Code:
for each w in workbooks
  if w.name = myWorkbookname then isitopen = true
next w
 

Watch MrExcel Video

Forum statistics

Threads
1,122,335
Messages
5,595,573
Members
413,996
Latest member
mabelO

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
Top