Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Open a Read-Only File by cycling thru these 5 passwords

one way:

Public Sub OpenFileWithCyclicPassword()
Const FNAME As String = "D:\Manager\Inventory.xls"
Dim i As Integer
Dim wBook As Workbook
Dim pwords As Variant

Application.ScreenUpdating = False
pwords = Array("applepie", "orangejuice", "bananasplit", _
"icysundae", "cheezebun")
On Error Resume Next
For i = 0 To UBound(pwords)
Set wBook = Workbooks.Open(FNAME, _
ReadOnly:=True, password:=pwords(i))
If Not wBook Is Nothing Then Exit For
Next i
On Error GoTo 0
ThisWorkbook.Sheets("Sheet1").Range("B6").Value = _
wBook.Sheets("Sheet1").Range("Q3000").Value
wBook.Close savechanges:=False
Application.ScreenUpdating = True
End Sub


In article ,
"Edmund Seet" wrote:

"D:\Manager\Inventory.xls" is a Read-Only file which is
protected by either one of these 5 passwords (applepie,
orangejuice, bananasplit, icysundae or cheezebun). My
manager will vary the password periodically but it will
always be either one of these 5.

My active workbook is named "Target.xls". I need a macro,
to be put in Target.xls, that will go
open "D:\Manager\Inventory.xls" and cycle through these 5
passwords, then copy cell Sheet1!Q3000 to be paste-value
back to my Target.xls cell B6.

I tried recording a macro but to no avail. I don't know
why it couldn't record as I only can get.....

Sub Macro4()
'
' Macro4 Macro
' Macro recorded 8/30/2003 by Edmund Seet
'

'
Range("C6").Select
End Sub

Please help me to complete this macro.

TIA
Edmund Seet (VBA rookie)

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Open a Read-Only File by cycling thru these 5 passwords

Million thanks to J.E.McGimpsey.


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
FILE CAN ONLY OPEN AS READ ONLY vcff Excel Discussion (Misc queries) 2 November 18th 08 11:18 AM
Can't Open a Read-Only file in Excel 03 Josh C Excel Discussion (Misc queries) 0 February 12th 08 10:09 PM
pre-authorized to open a file without passwords? CCrew2000 Excel Discussion (Misc queries) 1 May 23rd 07 11:42 PM
2 separate passwords (both valid) to open file regi Excel Discussion (Misc queries) 3 October 2nd 06 04:55 PM
Excel file won't open because it' a read only file when it is not IanB Excel Discussion (Misc queries) 1 September 12th 05 01:28 PM


All times are GMT +1. The time now is 12:05 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"