1

I use Task Scheduler to automate a variety of nightly tasks using Excel. Typically the task opens a new instance of Excel, which in turn opens a specified file, which does some stuff and closes itself (and Excel).

Now I have a task that requires an add-in, and use of the add-in requires separate authentication. There is no way to pass my credentials - I have to manually authenticate when the add-in loads. Because the old-fashioned way always launches a new (unauthenticated) instance, I can't figure out how fully automate tasks that require the add-in.

One workaround would be to open an instance of Excel before I leave, authenticate for the add-in, and leave that instance open. Then I could theoretically schedule the opening of some file within that instance (as opposed to launching a new instance to open the file, as described above) and do whatever the tasks were that required the add-in.

Is it possible to do this, either directly by defining the task a certain way, or in a .bat file that I can run on a schedule?

Steve Rowley
  • 1,548
  • 1
  • 11
  • 18
  • `use of the add-in requires separate authentication.` How do you authenticate the Add-In? – Siddharth Rout May 15 '12 at 21:15
  • When Excel launches, the add-in loads. It displays a modal window where you can enter a username/password. You can dismiss the window, but if you try to use any add-in functions, the window pops up again. After you are authenticated, you can use the add-in however you like in whatever files you open in that instance of Excel. – Steve Rowley May 15 '12 at 22:35
  • 1
    Ok now we have 2 options 1) Easy Way and the 2) Hard Way. Easy way is as you suggested. `open an instance of Excel before I leave, authenticate for the add-in, and leave that instance open` The hard way would be to use FindWindow/SendMessage API and automate the authentication process. – Siddharth Rout May 15 '12 at 22:43
  • Thanks @Siddharth. The Easy Way doesn't work as far as I know; Task Scheduler opens files by calling the executable with a file name as the argument, which means if you open an Excel file with Task Scheduler, it opens in a new instance. I'm not familiar with the API you mentioned, but, by the power of Google, I hope to try it. Appreciate the help! – Steve Rowley May 16 '12 at 01:55
  • Before you go down the hard way, I have a quick question for you. Which executable is being called by Tsk Schd? – Siddharth Rout May 16 '12 at 07:49
  • It calls EXCEL.EXE. It's equivalent to invoking "path\to\EXCEL.EXE" "path\to\file.xlsm" from the command line. – Steve Rowley May 16 '12 at 11:25
  • 1
    Ah! you dont need to do that. You can invoke an existing instance of Excel and then open the excel file using VBScript :) See this link http://stackoverflow.com/questions/10211250/problems-sending-outlook-email-from-excel-vba Instead of `CreateObject`, you use `GetObject` – Siddharth Rout May 16 '12 at 11:27
  • Ah, good ol' VBScript. You are right, that will do the trick. Thanks! – Steve Rowley May 16 '12 at 14:09

1 Answers1

0

I have a very similar problem and wondering if you have solved this problem through the VBA (getobject(), sendmessage method etc) yet. I created a seperate question on this just show what I have done. Windows FindWindows and SendMessgae for Auto-authentication excel VBA Basically I am stuck on how to pass user name and password to the add-in pop up window.

Thanks a million times:)

Community
  • 1
  • 1
YoYue
  • 41
  • 2
  • 7