+ Reply to Thread
Results 1 to 2 of 2

Execute macro logged in as another user

  1. #1
    Registered User
    Join Date
    04-29-2009
    Location
    nashville
    MS-Off Ver
    Excel 2007
    Posts
    6

    Execute macro logged in as another user

    Hey guys, I hope all is well. I hope someone can help me out with my issue that I cannot seem to resolve. I know I'm missing something simple (hope simple) here but cannot for the life of me figure it out. I have setup a process that is controlled by an SSIS package that:

    1.) Runs a stored proc from a SQL 2005 DB. This SP loads data into a SQL table.
    2.) The SSIS package then fires off a .vbs script that opens an excel spreadsheet and runs 4 different macros that extract the data from the SQL table, format the columns, extracts another chunk of data, and formats again.

    This SSIS package does this exact same thing for about 5 Excel spreadsheets. This package and all macros work perfectly when I'm logged into my machine and run it. But when I log into my machine as a different user and try to run the macros I get an error stating:

    Connection Failed:
    SQLState: '28000'
    SQL Server Error: 18456
    [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'NET\DCUXXXX'

    I also am attaching a word document with 2 print screens in it (zipped due to over 100kb's). One is that above message and the other is a SQL Server Login that pops up after the first error message asking for logging in. If I enter the login info in the SQL Server Login screen it works. But when I'm logged in as me I have this setup to run 100% without prompts. I know the login information (2nd User) I've entered in the VBA code in excel is correct as I've logged straight into the DB using it. I've also made sure that the references I use in my login (VB for Apps, MS Excel 12.0 Object Library etc) for Excel are added to the 2nd users Excel references, the main one being MS ActiveX Data Objects 2.0.

    Still not sure why I can't run a macro that I use daily without problems from a 2nd users login. Does anyone have thoughts on this?? Also, I have the same data sources set up for me as the 2nd user. Still stumped though : (

    One more worry, if you look at the 2 print screens, it's trying to use 2 different logins even though in my code I am only telling it to use one. Weird to me. I can post code if necessary, thought someone would know what I'm missing without it. Thanks for the time guys!!
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    04-29-2009
    Location
    nashville
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Execute macro logged in as another user

    I was able to work this out by changing the VB code for connecting to the server. I removed the "Trusted Connection" bit and replaced with the below:

    With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _
    "ODBC;DRIVER=SQL Native Client;SERVER=XX.XXX.XXX.XXX;UID=USERNAMEHERE;PWD=PASSWORDHERE;APP=Microsoft Office XP;WSID=WSID" _
    ), Array(";DATABASE=DBNAMEHERE;")), Destination:=Range("A5"))
    .CommandText = Array( _

    This works on other users machines now without prompting them for loggin info.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1