Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default vba code for opening password protected workbook

Is it possible for somebody to tell me the code i would need to open up a
password protected workbook, update the linked worksheets inside, then save
and close.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default vba code for opening password protected workbook

Here is a example for all workbooks in a folder
http://www.rondebruin.nl/copy4.htm

You can see the code that you must use on that page
If you need more help post back

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Carl Irving" wrote in message ...
Is it possible for somebody to tell me the code i would need to open up a
password protected workbook, update the linked worksheets inside, then save
and close.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default vba code for opening password protected workbook

Sub OpenPassword()
Dim wbk As Workbook

Application.DisplayAlerts = False

Set wbk = Workbooks.Open(Filename:="", _
UpdateLinks:=True, _
Password:="")

With wbk
.Save
.Close
End With

Set wbk = Nothing
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default vba code for opening password protected workbook

Thanks guys thats brilliant, unfortunately it used to ask me for 2 passwords
and it still tells me to enter a password for write access or open as read
only, is there a way to bypass this password too?

"Dave Miller" wrote:

Sub OpenPassword()
Dim wbk As Workbook

Application.DisplayAlerts = False

Set wbk = Workbooks.Open(Filename:="", _
UpdateLinks:=True, _
Password:="")

With wbk
.Save
.Close
End With

Set wbk = Nothing
End Sub


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default vba code for opening password protected workbook

See the example on my page

Set mybook = Workbooks.Open(MyPath & MyFiles(Fnum), _
Password:="ron", WriteResPassword:="ron", UpdateLinks:=0)


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Carl Irving" wrote in message ...
Thanks guys thats brilliant, unfortunately it used to ask me for 2 passwords
and it still tells me to enter a password for write access or open as read
only, is there a way to bypass this password too?

"Dave Miller" wrote:

Sub OpenPassword()
Dim wbk As Workbook

Application.DisplayAlerts = False

Set wbk = Workbooks.Open(Filename:="", _
UpdateLinks:=True, _
Password:="")

With wbk
.Save
.Close
End With

Set wbk = Nothing
End Sub




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default vba code for opening password protected workbook


Hi Ron,

Sorry to be a pain but i cant get this to work, im obviously doing something
wrong, do i just need those 2 lines you gave me or is there something else i
need to insert, both my files are in the same folder as suggested.

"Ron de Bruin" wrote:

See the example on my page

Set mybook = Workbooks.Open(MyPath & MyFiles(Fnum), _
Password:="ron", WriteResPassword:="ron", UpdateLinks:=0)


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Carl Irving" wrote in message ...
Thanks guys thats brilliant, unfortunately it used to ask me for 2 passwords
and it still tells me to enter a password for write access or open as read
only, is there a way to bypass this password too?

"Dave Miller" wrote:

Sub OpenPassword()
Dim wbk As Workbook

Application.DisplayAlerts = False

Set wbk = Workbooks.Open(Filename:="", _
UpdateLinks:=True, _
Password:="")

With wbk
.Save
.Close
End With

Set wbk = Nothing
End Sub



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default vba code for opening password protected workbook

In Dave's code you see

Password:="ron"

Now add this
WriteResPassword:="ron",

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Carl Irving" wrote in message ...

Hi Ron,

Sorry to be a pain but i cant get this to work, im obviously doing something
wrong, do i just need those 2 lines you gave me or is there something else i
need to insert, both my files are in the same folder as suggested.

"Ron de Bruin" wrote:

See the example on my page

Set mybook = Workbooks.Open(MyPath & MyFiles(Fnum), _
Password:="ron", WriteResPassword:="ron", UpdateLinks:=0)


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Carl Irving" wrote in message ...
Thanks guys thats brilliant, unfortunately it used to ask me for 2 passwords
and it still tells me to enter a password for write access or open as read
only, is there a way to bypass this password too?

"Dave Miller" wrote:

Sub OpenPassword()
Dim wbk As Workbook

Application.DisplayAlerts = False

Set wbk = Workbooks.Open(Filename:="", _
UpdateLinks:=True, _
Password:="")

With wbk
.Save
.Close
End With

Set wbk = Nothing
End Sub



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default vba code for opening password protected workbook

Hi Ron, i've copied Dave's code in like you said and added the line with the
write password instruction but it gives me a compile error/syntax error when
i try to run it. This is my code as i currently have it, i have tried putting
brackets and commas etc to separate the 2 password lines, i've even tried
them on the same line but everything returns the compile error.

Thanks

Carl


Sub OpenPassword()
Dim wbk As Workbook

Application.DisplayAlerts = False

Set wbk = Workbooks.Open(Filename:="e:\rota stuff\nick rota template", _
UpdateLinks:=True, _
Password:="united1")
WriteResPassword:="united1")
With wbk
..Save
..Close

End With

Set wbk = Nothing

End Sub

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default vba code for opening password protected workbook

Use it like this

Set wbk = Workbooks.Open(Filename:="e:\rota stuff\nick rota template", _
Password:="united1", WriteResPassword:="united1", UpdateLinks:=True)


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Carl Irving" wrote in message ...
Hi Ron, i've copied Dave's code in like you said and added the line with the
write password instruction but it gives me a compile error/syntax error when
i try to run it. This is my code as i currently have it, i have tried putting
brackets and commas etc to separate the 2 password lines, i've even tried
them on the same line but everything returns the compile error.

Thanks

Carl


Sub OpenPassword()
Dim wbk As Workbook

Application.DisplayAlerts = False

Set wbk = Workbooks.Open(Filename:="e:\rota stuff\nick rota template", _
UpdateLinks:=True, _
Password:="united1")
WriteResPassword:="united1")
With wbk
.Save
.Close

End With

Set wbk = Nothing

End Sub

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default vba code for opening password protected workbook

Thanks very much, that works a treat.

"Carl Irving" wrote:

Hi Ron, i've copied Dave's code in like you said and added the line with the
write password instruction but it gives me a compile error/syntax error when
i try to run it. This is my code as i currently have it, i have tried putting
brackets and commas etc to separate the 2 password lines, i've even tried
them on the same line but everything returns the compile error.

Thanks

Carl


Sub OpenPassword()
Dim wbk As Workbook

Application.DisplayAlerts = False

Set wbk = Workbooks.Open(Filename:="e:\rota stuff\nick rota template", _
UpdateLinks:=True, _
Password:="united1")
WriteResPassword:="united1")
With wbk
.Save
.Close

End With

Set wbk = Nothing

End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening a password-protected spreadsheet from a website link Héctor Miguel Excel Discussion (Misc queries) 0 August 17th 08 08:16 AM
password protected page not opening by web query vive2567 Excel Worksheet Functions 0 January 13th 06 03:20 AM
Opening password protected files Nick S[_13_] Excel Programming 3 November 9th 05 04:38 PM
Excel password protected not opening up on just one PC. M. Lord Excel Discussion (Misc queries) 2 July 25th 05 04:01 PM
how to automate opening a password protected excel file? e.g. a .xls that has a password set in the security tab. Daniel Excel Worksheet Functions 0 June 23rd 05 11:56 PM


All times are GMT +1. The time now is 01:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"