Consulting

Results 1 to 2 of 2

Thread: Supply Windows Username and Password via VBA

  1. #1
    VBAX Regular
    Joined
    Jan 2005
    Posts
    6
    Location

    Supply Windows Username and Password via VBA

    My current macro is running in one of the network PC with User-A login. When I execute the follwoing line, I get an error as User-A is not having access to view this file.

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.Getfile("//XXXXX/XXXXX/ABC.xlsm")
    Set SrcBook = Workbooks.Open(f)

    Just before executing this code, can we change windows logon Username and password to another user say User-B who has the access to this file?

    Finally I would like to revert back to User-A logon.
    __________________
    Regards
    GNaga

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    By forum rules, password questions can not be asked nor answered.

    What I can tell you is that Excel workbooks do not ask or use a window's username unless specifically coded to do so. So, yes, I could give you code to change the username but by rule, I can not do so. The designer of the program has designed it so that you must be a valid user to use it. We have no way to know that.

    In your code, just put the string name for the workbook in the open, there is no reason for fso. Of course workbooks.open allows you to send a password to open it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •