|
-
Dec 4th, 2001, 07:57 PM
#1
Thread Starter
Lively Member
open password protected Excel file
I would like to write code that will open an MS Excel file through code. The address will be hard coded into the program. I know to use Shell(), but the excel file is password protected and I would like to send the password to the file via code so the user doesn't have to enter it. Can it be sent via a command line switch? If so, what is the switch and syntax? If not, is there another way (aside from SendKeys())?
I know what you are thinking "why have a password in the first place if you don't want the user to use it?". Well, that's a valid question, but the answer is a long story that I'd rather not get into.
Any help is greatly appreciated.
Thanks,
Darrin@CB69
-----------------------------------------------
Arrogance kills brain cells
-----------------------------------------------
Private Sub Sandwich (big As Byte)
On Error GoTo Pub
-
Dec 4th, 2001, 07:59 PM
#2
PowerPoster
It's a reasonalbe thing to pwd-prot a file so you can make a restricted front end. I've only ever done this with Access, where I send the password through an ADO connection string.
Haven't done it with Access.
Can ADO access Excel??
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
-
Dec 4th, 2001, 10:14 PM
#3
Frenzied Member
Add a reference to the Microsoft Excel object library (versions may vary) and then use this:
VB Code:
Dim strPath As String
Dim strPass As String
strPath = "c:\MyWorkbook.xls" 'Make this the path of the spreadsheet
strPass = "1234567890" 'Make this the password
Dim XlApp As New Excel.Application
XlApp.Workbooks.Open strPath, , , , strPass
XlApp.Visible = True
Obviously you'll have to modify the strPath and strPassword vars to suit your purpose.
Hope this helps,
Nishant
You just proved that sig advertisements work.
-
Dec 4th, 2001, 10:24 PM
#4
Thread Starter
Lively Member
many tanks
sounds good, i will try it
thanks for your help
Darrin@CB69
-----------------------------------------------
Arrogance kills brain cells
-----------------------------------------------
Private Sub Sandwich (big As Byte)
On Error GoTo Pub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|