Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Open w/ Password Auto Supplied?

Status
Not open for further replies.
Jul 22, 2002
25
US
To make it simple, I have a complicated front-end in Excel VBA that saves worksheets (not the workbook). I change the file extension of the worksheets when I save them, just to keep stupid people away in Explorer listings. I also give them a password when I save them.

NOW, I want to open one of these "data" files. I need to get a listing of the possible choices (file extension ".abc"), have the program supply the password, and then load it into Excel.

Possible? (Using Office/Excel 2000 standard)

Thanks,

Mr. Pickles
 
This'll loop thru a folder and get the filenames with .abc at the end
Sub getFilenames()
Dim filename As String, r As Integer, lRow As Integer
'Define variables

filename = Dir$("\\Your\Folder\Path\Goes\Here\*.abc")
'Start File Search
Range("A2").Activate

Do While filename <> &quot;&quot;
ActiveCell.Offset(r, 0) = filename
r = r + 1
filename = Dir$()
Loop
End Sub

To open in excel, you'll need to set the program to open them with initially (ie excel). To supply the passwor...well that depends on how you give the password in the 1st place
Hope this points you in the right direction Rgds
~Geoff~
 
xlbo,

Thanks for the reply. I'm doing what you suggested, slightly modified. Concerning the password &quot;giver&quot;, it is in the

ActiveWorkbook.SaveAs

command, using the Password option

Now all I got to do is get the range of filenames and stick it in a listbox so someone can pick the one they want...

Thanks

Mr. Pickles
 
Interesting - how are you getting the passwords back...??? - are they standard passwords ??? - makes sense for them to be I s'pose Rgds
~Geoff~
 
Well, come to find out, I'm not getting them back.

Actually, in the saveas command you can specify the password, so I made a standard one. But when I go to open (Workbooks.Open) the file to import the data, there doesn't appear to be a way to specify the password via VBA.

unless it is hidden in there somewhere........

Mr. Pickles
 
Nevermind. Brain Fart issue resolved.

Workbooks.Open DOES have the password in it, so I am now saving and loading password protected files.

Ain't help files wonderful....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top