Excel VBA help...

Associate
Joined
20 Oct 2002
Posts
1,970
Location
Pateley Bridge, North Yorkshire
Hello,
Please can you help...

Thanks in advance! :)


Two Workbooks:
Book1.xls
Book2.xls

Book2.xls contains links to Book1.xls
Book1.xls contains a password to open: "abc"

I need to update the links in Book2.xls from Book1.xls without entering the password.

I've written this code however, it doesn't actaully update the links!!
Can you think where I could be going wrong?
Is it even possible?


Private Sub Workbook_Open()

Application.AskToUpdateLinks = False
Workbooks.Open Filename:="Book1.xls", Password:="abc"
Windows("Book2.xls").Activate
Calculate
Workbooks("Book1.xls").Worksheets("Sheet1").Activate
Range("A1").Select
ActiveWorkbook.Close SaveChanges:=False
Windows("Book2.xls").Activate
ActiveWorkbook.Close SaveChanges:=True

End Sub
 
Try this

Private Sub Workbook_Open()
Workbooks.Open Filename:="book1.xls", Password:="abc"
Calculate
Workbooks("book1.xls").Close
End Sub
 
Hi A[L]C

I've just tried your solution at home using Excel 2007 in compatibilty mode and it's worked. So simple too!
I'll try it tomorrow at work in Excel 2003 and keep my fingers crossed.
Cheers,

BH
 
Worked a treat. Many Thanks again.
It's amazing how many references there are to this situation around the web, but no solutions and yet it's such a simple piece of code! Weird.
 
Back
Top Bottom