Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've got a bunch of password-protected Excel workbooks on my secured LAN (no wan) computer.

Is it possible to parse the password into a shortcut so it would automatically open a workbook as long as the password is correct?

For example:

"S:\resources\Audit.xls" -password "mypass"
share|improve this question
2  
Can you please clarify; is the file password protected on open or just the sheets within the workbook are protected? There is a big difference between the two. –  CharlieRB Jun 19 '12 at 16:38
    
just the file is protected, once your in the sheets within are all open for access –  Owen Melbourne Jun 19 '12 at 16:46

1 Answer 1

There is no direct way, but with a little coding, you can get Excel to process command line parameters and open it from a launcher spreadsheet.

Using a shortcut that looks like this:

"C:\Program Files\Microsoft Office\Office12\EXCEL.EXE" /e/myfilename/mypassword "C:\MyExcelFiles\test.xlsb"

You can use the following code to get the command line - you will then have to extract the parameters you passed with /e, as the whole line gets returned

Declare Function StrLenA Lib "kernel32.dll" Alias "lstrlenA" (ByVal Ptr As Long) As Long
Declare Function GetCommandLineA Lib "kernel32.dll" () As Long
Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef pDst As Any, pSrc As Any, ByVal ByteLen As Long)

Function GetCommandLine() As String

Dim CmdStr As Long
Dim N As Long
Dim Buffer As String

   CmdStr = GetCommandLineA 'Get a pointer to a string, which contains the command line
   N = StrLenA(CmdStr) 'Get the length of that string
   Buffer = String(N, Chr$(0)) 'Create a buffer
   CopyMemory ByVal Buffer, ByVal CmdStr, N 'Copy to the buffer
   GetCommandLine = Buffer

End Function
share|improve this answer
    
seems like an answer –  datatoo Jun 28 '12 at 3:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.