none
Pass user credentials through vba

    Question

  • I have a vba program that opens another workbook on a server that I don’t want all the users to have access to.  So I want to setup a user on the server that does have access and then in the code I can pass the credentials.  This way, the file on the server can be opened as saved by the program instead of directly by the users.  However, I can’t figure out how to pass those credentials using vba.  Any ideas?

     

    Current code looks something list this:

    ActiveWorkbook.SaveAs Filename:="\\pretendserver\SSIS Uploads\Book2.xls", FileFormat:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False

    Wednesday, January 26, 2011 3:41 PM

Answers

  • The best you're going to be able to do is password protect the workbook and use VBA to open the document like you did in your code.

    Workbooks.Open Filename:="Path and FileName", Password:="XYZ", WriteResPassword:="XYZ"

    This will allow you open a workbook that requires both a password to open the workbook and one to unlock the write-reserved feature. Does this not work for you?

    Will Buffington
    Microsoft Excel Support

    • Marked as answer by Bruce Song Tuesday, February 15, 2011 9:56 AM
    Friday, January 28, 2011 10:10 PM

All replies

  • The best you're going to be able to do is password protect the workbook and use VBA to open the document like you did in your code.

    Workbooks.Open Filename:="Path and FileName", Password:="XYZ", WriteResPassword:="XYZ"

    This will allow you open a workbook that requires both a password to open the workbook and one to unlock the write-reserved feature. Does this not work for you?

    Will Buffington
    Microsoft Excel Support

    • Marked as answer by Bruce Song Tuesday, February 15, 2011 9:56 AM
    Friday, January 28, 2011 10:10 PM
  • Hello,

    I have the exact same issue, and Will's answer won't work for me.

    Did you manage to find how to open the files with other credentials?

    Jacques

    Tuesday, October 22, 2013 8:38 AM