locked
Windows 10 2004 Task Scheduler VB.NET Microsoft.Office.Interop.Excel will not run. RRS feed

  • Question

  • I have a massive amount of office automation and on 06/08 task scheduler stopped working the task runs but when it gets to create Excel Object it fails.    I see the Writeline Excle Create-START but nothing else.  If I change "Run only when user is logged on" it works but "Run whether user is logged on or not" fails.  it's my account with local admin rights nothing has changed that I am aware of.  

    Private Sub Excel_Create()
    
            
    
            WriteLinetoLog(strLogPath, " UserID:" & UserName & " PC:" & MachineName & " Excel_Create-START")
    
            Try
    
                'Export to Excel process
                Dim Excel As Object = CreateObject("Excel.Application")
    
                With Excel
                    .SheetsInNewWorkbook = 3
                    .Workbooks.Add()
                    .Worksheets(1).Select()
                    .WorkSheets(1).Name = "Sheet1"
                    .WorkSheets(2).Name = "Sheet2"
                    .WorkSheets(3).Name = "Sheet3"
    
    
                    .Application.DisplayAlerts = False
    
                    .ActiveCell.Worksheet.SaveAs(LoadDir & "SDC-Excel_Create.xls", XlFileFormat.xlExcel8)
                    .Workbooks.Close()
                    .Excel.Quit()
                    Runtime.InteropServices.Marshal.ReleaseComObject(Excel.Application)
                End With
    
            Catch ex As System.Exception
                'MsgBox(ex.ToString)
                WriteLinetoLog(strLogPath, " Exception: " & ex.ToString)
            End Try
    
            WriteLinetoLog(strLogPath, " UserID:" & UserName & " PC:" & MachineName & " Excel_Create-END")
    
        End Sub



    Work Smarter Not Harder


    Friday, June 12, 2020 5:19 PM

Answers

  • This has been resolved.  kind of a perfect storm,  Azure and Task Scheduler Credentials don't work and had to create a local account to run these task.  When windows did the last update and basically you get a new profile when you first login.  that local account did not work until I physically logged in to create the new profile as well as I had to open excel.     

    Work Smarter Not Harder

    • Marked as answer by jimbrown.net Thursday, June 18, 2020 1:44 PM
    Thursday, June 18, 2020 1:44 PM

All replies

  • Do you have these settings?


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Sunday, June 14, 2020 3:55 PM
  • Yes, of course.  "Run whether user is logged on or not" fails.  you can see that the tasks starts as I state I see debug "Writeline Excle Create-START but nothing else."      It's failing to create Excel Object.  FYI Office 365 and Azure AD    

    Work Smarter Not Harder




    Sunday, June 14, 2020 4:34 PM
  • Hi jimbrown.ws,
    Based on your description, I have some suggestions you can refer to.
    1.Change DCOMCNFG settings of Excel to run using the interactive account.
    2.Click "Change user or group..." >Advanced> Locations: select Whole Active directory, type in starts with the name of your account. Then find now and pick the account from search results. 
    More details you can refer to these documents.
    [Excel COM automation via interactive user stops working when user logs off]
    [Task Scheduler Problem (run whether user is logged on or not)]
    Hope these are helpful to you.
    Best Regards,
    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, June 15, 2020 5:11 AM
  • I have looked at 3 PC on our Azure AD / Office 365 platform and they all don't have DCOM Config Microsoft Excel Application.  our old PC connecting to Windows Server 2012R2 AD accounts with Office 2016 have DCOM Config Microsoft Excel Application and those PC work with Task Scheduler "Run whether user is logged on or not."    I have also had to created C:\WINDOWS\system32\config\systemprofile\Desktop when Windows updates as Task Scheduler will not run without this directory.     only possible workaround is to have user logged in,  this posses a security risk and obviously Microsoft has some bugs in Task Scheduler and Azure AD credential that needs worked out.         

    Work Smarter Not Harder



    Monday, June 15, 2020 1:42 PM
  • Hi jimbrown.ws,
    This forum is discussing and asking questions about the Windows Forms such as Winforms controls, libraries, samples, publication and installation.
    So I will move it to "where is the forum for" form and people in this forum will move the case to the correct forum.
    I hope you can get more professional answer in correct forum.
    Thank you for your understanding.
    Best Regards,
    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, June 16, 2020 8:07 AM
  • Tuesday, June 16, 2020 8:21 AM
  • Also try asking for help over here.

    https://social.msdn.microsoft.com/Forums/Lync/en-US/home?forum=exceldev

     

     



    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    • Proposed as answer by Guido Franzke Tuesday, June 16, 2020 12:46 PM
    Tuesday, June 16, 2020 12:00 PM
  • This has been resolved.  kind of a perfect storm,  Azure and Task Scheduler Credentials don't work and had to create a local account to run these task.  When windows did the last update and basically you get a new profile when you first login.  that local account did not work until I physically logged in to create the new profile as well as I had to open excel.     

    Work Smarter Not Harder

    • Marked as answer by jimbrown.net Thursday, June 18, 2020 1:44 PM
    Thursday, June 18, 2020 1:44 PM