Automation error the object invoked has disconnected from its clients

I know I've seen references to this issue before, but I have tried several of the suggestions and I am still getting the error. I have a workbook that assembles data from another book and generate...

I know I’ve seen references to this issue before, but I have tried several of the suggestions and I am still getting the error. I have a workbook that assembles data from another book and generates a report. I then want to make a new workbook, copy the report information into the new book, save the new book and close it, and then move on to the next report. It should do this around 10 times. In the part of my code where I am copying and pasting the sheets, I am getting an error

Error -2147417848 Automation error The object invoked has
disconnected from its clients

I have checked other postings about this error, and tried the suggested solutions without any results. the interesting thing is that sometimes it will make it through 5 cycles of code before breaking, sometimes only 2. The only consistency is that it always breaks in the same place

fromBook.Sheets(«Report»).Copy Before:=newBook.Sheets(«Sheet1»)

I have option Explicit at the top of the module, and I have checked to make sure that there are not any globals inside of the sub it is breaking in. That being said, It’s entirely possible I have overlooked something. I also put a «timer» in at one point to make sure that the excel sheets were not walking over each other.

I could really use the help!

Here is my sub’s code:

Sub CreateAndSave(ByRef Reg As Integer, ByVal j As Integer)

        Dim fromBook As Workbook
        Dim fromSheet As Worksheet
        Dim newBook As Workbook
        Dim fileExists As Boolean
        Dim i As Integer
        Dim Holder As Integer


        Application.ScreenUpdating = False
        Application.DisplayAlerts = False

            Set fromBook = Application.Workbooks("Region_Audit_Report")
            Set newBook = Workbooks.Add

           With newBook
            .SaveAs Filename:="G:DataTeamExcelDevAudit ReportRegion WorkbooksRegion" & Reg & " " & Month(Date) & "-" & Day(Date) & "-" & Year(Date) & ".xlsx" _
            , FileFormat:=xlOpenXMLWorkbook
           End With

        Set newBook = Application.Workbooks("Region" & Reg & " " & Month(Date) & "-" & Day(Date) & "-" & Year(Date) & ".xlsx")

        fromBook.Sheets("Report").Copy Before:=newBook.Sheets("Sheet1")
        fromBook.Sheets("MonthData").Copy After:=newBook.Sheets("Report")

        newBook.Sheets("MonthData").Range("A1") = "Month"
        newBook.Sheets("MonthData").Range("B1") = "Store#"
        newBook.Sheets("MonthData").Range("C1") = "District"
        newBook.Sheets("MonthData").Range("D1") = "Region"
        newBook.Sheets("MonthData").Range("E1") = "Due Date"
        newBook.Sheets("MonthData").Range("F1") = "Comp Date"
        newBook.Sheets("MonthData").Range("G1") = "# of Errors"
        newBook.Sheets("MonthData").Range("H1") = "Late?"
        newBook.Sheets("MonthData").Range("I1") = "Complete?"

        newBook.Sheets("MonthData").Range("A1:I1").Interior.ColorIndex = 43


            newBook.Save

            newBook.Close


            Application.DisplayAlerts = True

    End Sub

RRS feed

  • Remove From My Forums
  • Question

  • I got this error: «Automation error: The object invoked has disconnected from its clients» when I try to save a document(Word), spredsheet(Excel) etc. in Office 2010.

    I try it for office 2007 /2003, the issue is same.

    It is a new error, my Office have worked fine with this installation before.

All replies

  • Hi,

    Can you check if the Security Update MS12-060 has been installed ?
    If so, please try the following on a test machine.

    Open Notepad and paste the content below the line.
    Save the File as .bat and run it. Try again Word to see if you get the message.

    ===============================================

    reg delete hkcrtypelib{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}2.0 /f

    if exist %systemroot%SysWOW64cscript.exe goto 64 
    %systemroot%system32regsvr32 /u mscomctl.ocx
    %systemroot%system32regsvr32 mscomctl.ocx
    exit

    :64 
    %systemroot%sysWOW64regsvr32 /u mscomctl.ocx
    %systemroot%sysWOW64regsvr32 mscomctl.ocx
    exit

    ===============================================

    Take a look also at this one: http://blogs.technet.com/b/the_microsoft_excel_support_team_blog/archive/2012/08/15/quot-unspecified-automation-error-quot-after-applying-ms12-060.aspx

    Cheers, Petru

  • Appreciate your quick reply.

    I have try to run your .bat file, but occurred this error message, means «Mscomctl.ocx has been loaded successfully but failed to call DllRegisterServer, the error code is 0x80004005.»

    • Edited by

      Monday, August 27, 2012 3:31 AM

  • @Logoncafe, please try to then run the script again with Administrator permission, hold Shift key and right click on it, and choose Run as administrator.


    Max Meng
    TechNet Community Support

    • Edited by
      Max Meng
      Wednesday, August 29, 2012 4:25 AM

  • Hi Max Meng,

    I execute the about scripts successfully, but the automation error still exists. -_-!

  • ehmmm…

    Try to run Word in safe mode, and save the document again.

    If this error won’t occur in the safe mode, remove the macros or disable the add-ins and check again.


    Max Meng

    TechNet Community Support

  • Any updates/ fresh insights on this? 

    I get the exact same error when trying to use «Save as» from Excel.  I get it regardless of the state of the document, whether I try to save an empty document from a freshly opened Excel session or if I try to «Save as» an existing document. Just using
    Save on an existing document does not initiate the error.

    In Word I get the message only sporadically when trying to save.

    I have tried the registry fix to no avail and running in safe mode does not make any difference. 

    I tried reinstalling Microsoft Office (2007) — that did not help. Today IT department rolled out Office 2010 and I installed that, but I still get the same error.

    As for the OP my problems started recently, and without remembering the exact date it was definitely later than the  15th of August (time of the infamous patch).

    We are a pretty big organisation, and as far as I know none of my colleagues have the same problem and our IT helpdesk is miffed.

    The only solution left to me now is to reinstall windows unless some clever soul in here have a tip that might remedy the issue.

    • Edited by
      olecs
      Monday, September 10, 2012 12:42 PM

  • I, too, was still having the error message in Excel 2010 on one user’s computer.  I even tried creating a clean Excel14.xlb file, but that didn’t make a difference.

    At this point I knew it was likely to be an add-in creating the issue since I was getting this error message just opening Excel without actually opening an existing file.

    I went to File>Options>Add-Ins>Excel Add-Ins and unchecked «Analysis Toolpak — VBA», closed Excel, opened Excel and the message had gone away.

    Then I enabled the Add-In again, but the error message did not return.  So far, so good, but time will tell if this was the fix. 

    What actually happened under the hood, though? 


    Views expressed do not represent those of my employer.

  • Remove From My Forums
  • Question

  • Need help with an explanation and solution to this problem.

    The code below creates a workbook that receives a pair of sheets from the main workbook.  The code will run all day long, deleting and recreating SavNm for every time the macro is ran.  The problem is when SavNm is opened and closed, subsequent
    running of the macro somehow loses reference to a newly created SumWb.  The copy accually completes to SumWb, but the workbook cannot be accessed after that.  Any enlightenment would be appreciated.

    OldDAS

    Sub CreateSummaryFiles(w)
        Dim SavNm, OpnNm As String
        Dim btm As Integer
        Dim SumWb As Object
        Dim Fobj As Object

       
        SavNm = «Summary » & Qtr & » » & TargWk & «.xlsx»
        If Dir(SumDir & SavNm) <> «» Then ‘if an old SavNm exists…delete it
            Set Fobj = CreateObject(«Scripting.FileSystemObject»)
            Fobj.deletefile SumDir & SavNm
            Set Fobj = Nothing
        End If

       
        If Dir(SumDir & SavNm) = «» Then ‘create new SumWb for the one just deleted
            Set SumWb = Workbooks.Add
            ‘The following line will run all day without incident, deleting and recreating SavNm.
            ‘If SavNm is opened then closed, subsequent running of the macro halts on the following line
            ‘with an Automation Error «the object invoked has disconnected from its client»
            ‘after that SumWb cannot be referenced.
            Sheets(Array(«Summary», TargWk)).Copy Before:=SumWb.Sheets(1)
            SumWb.Activate
            SumWb.Sheets(3).Delete
            Sheets(1).Select
            NewBlue Avgs(w, 0)
            ‘do other code bla, bla bla….
            SumWb.SaveAs SumDir & SavNm
            SumWb.Close
        End If
    End Sub

    • Moved by

      Friday, June 6, 2014 1:57 PM
      Excel dev

Contents

  • What is The object invoked has disconnected from its clients error message?
  • How to remove The object invoked has disconnected from its clients message from Windows logon?
    • Revert to a previous restore point
    • Enable Secure Boot
    • Reinstall Windows
  • How can I fix The object invoked has disconnected from its clients error?
    • Reboot your PC
    • Choose a different default program
    • Restart Windows Explorer

How to fix The object invoked has disconnected from its clients?

Of all the bugs that can affect your PC, the one that prevents you from logging in or opening your files must rank among the worst. Imagine trying to access your work documents, only to be confronted by the The object invoked has disconnected from its clients error message. Frustrating, right? You are not alone; many Windows users have been expressing their profound annoyance at this error, which basically renders files of a certain type redundant since they are unable to be opened.

We have come across two manifestations of this weird Windows bug. Some people get this error after starting up their computers. They get stuck on the Windows login page, which merely flashes the The object invoked has disconnected from its clients error message without accepting any user credentials. The more common iteration of this error occurs when trying to open files in certain formats. From the online chatter about this error, videos, photos, music files, word documents and Excel spreadsheets seem to be the most affected. Rarely, it even prevents certain applications from launching.

What is The object invoked has disconnected from its clients error message?

Despite the complicated-sounding jargon, this error message actually communicates something pretty simple. Whenever you get the The object invoked has disconnected from its clients message on Windows, it simply means that the specific program assigned to open files of a certain type is unable to do so. The object refers to a particular app on your PC that you have chosen to open the kind of file you’re trying to open. Its clients naturally refers to this file type. The whole error message thus tells you that the files can’t be opened because the program associated with them has been disconnected for some reason.

Other users see this error when they are trying to save their files, especially Word and Excel documents. The message appears, and the file can’t get saved. The message looks like this:

Automation error

The object invoked has disconnected from its clients

No matter what variant of the error you get or whether it is inability to access files or log in to your computer, there is no denying that this error impacts negatively on the affected users. Therefore, we have come up with some tried and verified solutions to this issue. We will first deal with the Windows logon error. After that, we will show some fixes for those who are unable to open their files because of this error.

How to remove The object invoked has disconnected from its clients message from Windows logon?

Practically, getting this error on the Windows logon screen is a real headache Without being able to access Windows, it becomes much harder to troubleshoot. Even so, there are effective methods to get rid of this error and regain access to your computer. These methods have worked for a lot of people, and there is no reason they shouldn’t work for you too.

  • Revert to a previous restore point

Getting the message The object invoked has disconnected from its clients when logging into Windows points to a systemic problem. This means that the cause must be something that has been changed in the system files. For example, this can happen if you have recently performed an update or installed a newer version of a Windows component or an application. You can try performing a restore to see if that fixes the issue.

Note that this method only works if you have previously enabled System Restore.

Tip: To enable System Restore in Windows 10, do the following:

  1. Type Create a restore point in Search and click the first item in the list of results. This will take you to System Properties > System Protection.
  2. Enable protection in Protection Settings.
  3. Click Configure to open up the configuration menu. You can allocate space on your hard drive for storing the restore files.
  4. When you’re ready to create a restore point, click the Create button.
  5. Return here to create a restore point before you install any major update or make significant changes to your PC.

Follow these steps to revert to a previous configuration. Since you can’t log into Windows, you have to use Windows Recovery Environment to perform a system restore:

  1. Click the power icon on the login screen.
  2. Press and hold Shift and click Restart.
  3. Wait as the computer restarts into the Choose an option screen.
  4. Click Troubleshoot, then Advanced options.
  5. Select System Restore.
  6. Wait for Windows to finish the restore process.

You might want to delete older restore points to save space on your computer. Also, after completing a restore, your PC might become a bit slower, Using Auslogics BoostSpeed will ensure that your system keeps motoring along nicely like a Formula One car. All you have to do is install it and let it perform a scan for junk files and other system-slowing items. It will delete those, keeping your PC fresh and less susceptible to annoying glitches and crashes.

  • Enable Secure Boot

You can solve the The object invoked has disconnected from its clients error on login by starting your PC with Secure Boot enabled. When triggered, this feature stops potentially harmful applications, unsigned drivers and unauthorized .exe files from being loaded when Windows starts up. If one of these is responsible for the error you’re getting, using Secure Boot should make it disappear.

To turn on Secure Boot, you have to go into your PC’s UEFI settings:

  1. Restart your computer.
  2. Once on the boot screen, press the appropriate key to bring up your PC’s UEFI.
  3. In UEFI, go to Security > Secure Boot.
  4. Enable Secure Boot if disabled.
  5. Save your changes and exit.
  6. Try logging in to see if the error is gone.
  • Reinstall Windows

After trying other methods without success, this is the last option you can take to remove the annoying message from your Windows login screen. Reinstalling Windows isn’t difficult if you have the installation CD. You can also use a bootable ISO stored on an external drive. Depending on the method you choose, you might need to enter your Windows product key.

  1. Place the bootable CD into your DVD drive or plug in the bootable external device.
  2. Choose Upgrade when prompted for what you want to do.
  3. Allow the process to complete.

You can still perform a reinstall, a refresh or a reset even if you don’t have a bootable media. All you have to do is boot into Windows RE like before:

  1. Boot into Windows RE.
  2. Select Troubleshoot from the Choose an option screen.
  3. Click Refresh your PC for a reinstall that keeps all your files and applications.
  4. Click Reset your PC if you want a clean reinstall of Windows. It will remove all your installed apps, files and settings.

How can I fix The object invoked has disconnected from its clients error?

If you can log into Windows without any problems but encounter the error when you try to open certain file types, then this section is for you. We will show you how to get rid of the error and regain access to your files.

  • Reboot your PC

This method also works for when stuck at the Windows login screen with the The object invoked has disconnected from its clients error message prominently displayed. It might not seem like much of a solution, but it is actually quite effective when dealing with errors, including this one in question. Sometimes, a restart is just what the doctor ordered for your Windows PC.

Press the power switch on your computer for a few seconds to shut down the system. Press it again to restart it. Alternatively, you can open the power icon at the bottom right of the Windows login screen and select Restart.

If you’ve recently performed an upgrade or update, there might be leftover files that require a restart to be removed. You can run Auslogics BoostSpeed for this purpose. It will find those leftover Windows installation files and delete them.

  • Choose a different default program

The error The object invoked has disconnected from its clients might be due to using native Windows applications to open files. Windows, of course, programmed some of its own applications to open photos, videos, etc. by default. If the default program isn’t working for you, then switching to another might be the solution.

The Photo app on Windows 10 has been fingered as a frequent casualty of the The object invoked has disconnected from its clients error. If this is the case for you too, you can replace it as the default image-viewing application by doing the following:

  1. Go to the location of the image file you are unable to open and right-click it.
  2. Select Properties.
  3. Click the Change button within the General tab to open it.
  4. This will bring up a window containing the image-viewing applications on your PC. Choose whichever one you like to make it your default program.
  5. Apply changes and exit.

If your selection doesn’t fix the issue, you can return to the General tab and make another app your default photo viewer. You can find quite a few image viewers on Windows Store. Most are free to download.

  • Restart Windows Explorer

A few users mentioned that restarting Windows Explorer had worked for them. You can as well try it too. There’s nothing to lose anyway.

  1. Open Task Manager.
  2. Find the running Windows Explorer executable in the Processes tab.
  3. Right-click it and select End task.

These, in a nutshell, are the most popular means of solving the error The object invoked has disconnected from its clients on Windows, as confirmed by research. Whether you can’t get past the login screen due to this error or you’re fruitlessly trying to open certain files because of it, there is a method here that should work for you. If you manage to solve the error by using one of the tips here, don’t forget to tell us about it in the comments.

 

vukula

Пользователь

Сообщений: 4
Регистрация: 23.11.2015

#1

23.11.2015 12:09:26

Excel 2010
Имеет место рандомная ошибка. Т.е. иногда возникает, иногда — нет.
«Run-time error ‘-2147417848 (80010108)’
Automation error. The object invoked has disconnected from its clients»

Если возникает, то дальнейший дебаг и запуск дает
«Run-time error ‘1004’: Метод Insert класса Range завершен неверно»

Помогите пжл. В каком направлении искать. Спасибо.

Код
Sub addOp()
    Dim Name As String
           
    Name = Cells(5, 2)
    Size = Cells(2, 2).Value
    Avr = Cells(6, 2).Value
    Eop = Cells(7, 2).Value
              
    Sheets("tmpl").Copy Before:=Sheets(13)
    Sheets("tmpl (2)").Name = Name
    
    Sheets(Name).Visible = True
    Sheets(Name).Select
    Cells(3, 2) = Name
    Cells(2, 1) = Size
    Cells(1, 2) = Avr
    Cells(2, 2) = Eop
       
'вставка в рублевый лист
    Sheets("tmplFrur").Visible = True
    Sheets("tmplFrur").Select
    Range("B1:B147").Select
    Selection.Copy
    Sheets("resumeRur").Select
    Range("C1").Select
    Selection.Insert Shift:=xlToRight    'вот на этой строке вылетает ошибка. А иногда не вылетает.
    Cells(1, 3) = Avr
    Cells(2, 3) = Eop
    Cells(3, 3) = Name
    Columns("c:m").ColumnWidth = 12.5
  
    
    Sheets("tmplFrur").Visible = False
    Sheets("tmplFcur").Visible = False
    Sheets(Name).Select
    Range("b4").Select
    Application.CutCopyMode = False
End Sub
 

CAHO

Пользователь

Сообщений: 2183
Регистрация: 25.02.2013

А она возникает скорее всего, потому что макрос у Вас из модуля выполняется и обращается к конкретным ячейкам листам и диапазонам через Select.
Уберите все селекты и лишние переменные, которые в начале даже не описаны. Пропишите нормальные пути к листам и ячейкам. У вас скорее всего не на те листы или имена попадает при выполнении макроса. А вообще пример бы.

Мастерство программиста не в том, чтобы писать программы, работающие без ошибок.
А в том, чтобы писать программы, работающие при любом количестве ошибок.

 

vukula

Пользователь

Сообщений: 4
Регистрация: 23.11.2015

#3

23.11.2015 12:43:54

Цитата
CAHO написал: Пропишите нормальные пути к листам и ячейкам

Что Вы подразумеваете под «нормальными путями»?
Пример, в смысле «файл»?

 

justirus

Пользователь

Сообщений: 295
Регистрация: 03.06.2014

#4

23.11.2015 12:49:46

Цитата
vukula написал: нормальные пути к листам и ячейкам

Ну например:
Name = Cells(5, 2)
можно заменить на:
Name = ThisWorkbook.Worksheets(«Параметры»).Cells(5, 2)
разница в том, что в зависимости от того какой лист или книга буду активны в момент запуска макроса, переменная name будет иметь разные значения, в моем варианте всегда одно значение.

Изменено: justirus03.12.2015 01:06:25

 

CAHO

Пользователь

Сообщений: 2183
Регистрация: 25.02.2013

#5

23.11.2015 12:57:10

Например что-то вроде такого

Код
Sub addOp()
    Name = Cells(5, 2)
    Sheets("tmpl").Copy Before:=Sheets(13)
    Sheets("tmpl (2)").Name = Cells(5, 2)
    Sheets(Name).Cells(3, 2) = Name
    Sheets(Name).Cells(2, 1) = Cells(2, 2).Value
    Sheets(Name).Cells(1, 2) = Cells(6, 2).Value
    Sheets(Name).Cells(2, 2) = Cells(7, 2).Value
    Sheets("tmplFrur").Range("B1:B147").Copy
    Sheets("resumeRur").Range("C1").Insert Shift:=xlToRight
    Sheets("resumeRur").Cells(1, 3) = Cells(6, 2).Value
    Sheets("resumeRur").Cells(2, 3) = Cells(7, 2).Value
    Sheets("resumeRur").Cells(3, 3) = Name
    Sheets("resumeRur").Columns("c:m").ColumnWidth = 12.5
    Sheets(Name).Range("b4").Select
    Application.CutCopyMode = False
End Sub

Мастерство программиста не в том, чтобы писать программы, работающие без ошибок.
А в том, чтобы писать программы, работающие при любом количестве ошибок.

 

vukula

Пользователь

Сообщений: 4
Регистрация: 23.11.2015

Спасибо за участие.
Минимизировал селекты, НО ошибка все равно вылетает.
Выявил следующую зависимость.
Файл сохраняется как шаблон эксель с поддержкой макросов.
Изначально Name забито как «2013» (т.е. год).
Если я открываю файл и запускаю макрос, не меняя Name, ошибка не вылетает.
Если открываю файл и ввожу первый отчетный период, отличный от сохраненного в шаблоне, например, 2014й, ошибка вылетает.
Файл вкладываю.

Изменено: vukula23.11.2015 17:20:59

 

vukula

Пользователь

Сообщений: 4
Регистрация: 23.11.2015

вот что говорит микрософт

правда мне это не помогло

Изменено: vukula24.11.2015 09:09:47

 

hyperion3330

Пользователь

Сообщений: 37
Регистрация: 22.10.2018

#8

13.07.2021 18:32:31

Недавно тоже столкнулся с такой проблемой..
Как оказалось — из-за того что пытался менять значения ячеек на скрытом листе..
Как только перенёс строку «Sheets(Name).Range(«b4″).Visible = True»
Перед изменением значений, сразу всё стало нормально работать :)
Вдруг кому-то пригодится…

  • Home
  • VBForums
  • Visual Basic
  • Visual Basic 6 and Earlier
  • [RESOLVED] Automation Error -2147417848 The object invoked has disconnected from its clients

  1. Feb 16th, 2006, 09:56 AM


    #1

    tward is offline

    Thread Starter


    Hyperactive Member


    Resolved [RESOLVED] Automation Error -2147417848 The object invoked has disconnected from its clients

    I’ve seen several posts about this but non that really help!

    I get this only when running the program as an executable….. Never in Visual Basic…

    I’ve isolated it to one routine, but can’t figure out what this message is trying to tell me… I trap the error now, and the program seems to continue to work just fine after the error… but I really think I should track it down!


  2. Feb 16th, 2006, 10:52 AM


    #2

    Re: Automation Error -2147417848 The object invoked has disconnected from its clients

    It comes probably from Data connection.

    Only way to find it, is writing tracking code, what writes all to the logfile.

    oh1mie/Vic


  3. Feb 16th, 2006, 10:58 AM


    #3

    tward is offline

    Thread Starter


    Hyperactive Member


    Re: Automation Error -2147417848 The object invoked has disconnected from its clients

    I am connected to an Access Database….

    I’ll do some logging to see if I can track it down.. Problem, of course, is that it is not consitent at all!

    I’m sure it will end up being something stupid that I am doing, but I just don’t see it right now….

    Didn’t know if anyone else had any insight!


  4. Feb 16th, 2006, 11:09 AM


    #4

    Re: Automation Error -2147417848 The object invoked has disconnected from its clients

    I got same kind of trouble 7 — 8 years ago. I can not remember solving.
    Error was on datadriver or dataconnection and there for VB did not show error like it’s owns.

    oh1mie/Vic


  5. Feb 16th, 2006, 11:11 AM


    #5

    Re: Automation Error -2147417848 The object invoked has disconnected from its clients

    Does it happen on every machine that your program runs on, or one just one or two?


  6. Feb 16th, 2006, 11:27 AM


    #6

    Re: Automation Error -2147417848 The object invoked has disconnected from its clients

    Do you use some datacontrol or just ado connection with out datacontrol?

    oh1mie/Vic


  7. Feb 16th, 2006, 11:38 AM


    #7

    Re: Automation Error -2147417848 The object invoked has disconnected from its clients

    I’ve had this error in the past, always on Win2000 (is that what you’re using). This error has many causes often related to some form of MS Office automation. Are you using any automation or do you use any of the Forms 2.0 objects, or maybe the Access Calender control MSCAL.OCX?


  8. Feb 16th, 2006, 11:49 AM


    #8

    Re: Automation Error -2147417848 The object invoked has disconnected from its clients

    I was thinking if textboxes or labels are bounded to database on with the control. If there is wrong database path on the label properties at the time when program goes the to form load and initialize control before it’s corrected on the code.

    Last edited by oh1mie; Feb 16th, 2006 at 12:03 PM.

    oh1mie/Vic


  9. Feb 16th, 2006, 12:32 PM


    #9

    tward is offline

    Thread Starter


    Hyperactive Member


    Re: Automation Error -2147417848 The object invoked has disconnected from its clients

    Lots of responses… Hopefully this answer all of the above! Thanks for all the help!

    1. Have only tried it on three machines, happens on all three. Doesn’t happen right
    away, and is sporatic, also doesn’t happen a ton.. It is tracked down to one
    function.

    2. No datacontrols. ADO connection.

    3. All Windows XP machines.

    4. Nothing is bound. I create the recordset and go through it to populate what I
    need.


  10. Feb 16th, 2006, 12:42 PM


    #10

    Re: Automation Error -2147417848 The object invoked has disconnected from its clients

    … and you don’t use any Forms 2.0 objects or the Access Calender Control, neither do you have any Office automation code??

    Edit: Also how do you deploy the application?

    Last edited by Joacim Andersson; Feb 16th, 2006 at 12:46 PM.


  11. Feb 16th, 2006, 03:25 PM


    #11

    tward is offline

    Thread Starter


    Hyperactive Member


    Re: Automation Error -2147417848 The object invoked has disconnected from its clients

    Correct, no Forms 2.0 objects, no access calendar and no Office automation!

    Right now it is only going to be used by one person in a business. All the runtime stuff installs and then I just give him the executable…

    But even on the development machine when using the executable I get the error??


  12. Feb 16th, 2006, 06:29 PM


    #12

    Re: Automation Error -2147417848 The object invoked has disconnected from its clients

    It is tracked down to one function.

    Can you show us the code for this function?


  13. Feb 16th, 2006, 09:23 PM


    #13

    tward is offline

    Thread Starter


    Hyperactive Member


    Re: Automation Error -2147417848 The object invoked has disconnected from its clients

    VB Code:

    1. Public Sub LoadItems(ByVal Category As String, ByVal CategoryButtonIndex As Integer, Optional ByVal IsSubCategory As Boolean = False)

    2.   Dim CatID As String

    3.   Dim Counter As Long

    4.   Dim TempDynaset As Object

    5.   On Error GoTo ErrorHandler

    6.   If IsSubCategory = True Then

    7.     Me.frameMain(1).Caption = " " & Trim(Me.frameMain(1).Caption) & "" & Me.ssrItems(CategoryButtonIndex).Caption & " "

    8.     CatID = Right(Category, Len(Category) - 7)

    9.   Else

    10.     Me.frameMain(1).Caption = " " & Category & " "

    11.     CatID = GetCategoryIDFromDescription(Category)

    12.   End If

    13.   If frmDeli32.ssrItems.Count > 1 Then

    14.     For Counter = frmDeli32.ssrItems.Count - 1 To 1 Step -1

    15.        Unload frmDeli32.ssrItems(Counter)

    16.     Next Counter

    17.   End If

    18.   Set TempDynaset = DatabaseOpenDynaset("frmDeli32.LoadItems", "SELECT * FROM MENU_ITEMS WHERE " & IIf(IsSubCategory = True, "SUBCATID='" & AddApostropheFunc(CatID) & "' OR SUBCATID LIKE '%" & AddApostropheFunc(CatID) & "~%'", "CATEGORYID=" & CatID) & " ORDER BY SEQUENCE,DESCRIPTION", gTraceSQL, 0)

    19.   If gDynaSetOpenError = False Then

    20.     If TempDynaset.RecordCount = 0 Then

    21.       frmDeli32.ssrItems(0).Visible = False

    22.     Else

    23.       ReDim gItems(TempDynaset.RecordCount)

    24.       ReDim gItemsIncludeAsTopping(TempDynaset.RecordCount)

    25.       frmDeli32.ssrItems(0).Caption = TempDynaset.Fields("DESCRIPTION").Value

    26.       frmDeli32.ssrItems(0).BackColor = frmDeli32.ssrCategories(CategoryButtonIndex).BackColor

    27.       frmDeli32.ssrItems(0).Visible = True

    28.       gItems(0) = IIf(TempDynaset.Fields("ISSUBCAT").Value & "" = "Y", "$$SC$$-", "") & TempDynaset.Fields("ITEM_CODE").Value

    29.       gItemsIncludeAsTopping(0) = TempDynaset.Fields("INCLUDEASTOPPING").Value

    30.       Dim IconFileName As String

    31.       For Counter = 0 To TempDynaset.RecordCount - 1

    32.          If Counter > 0 Then

    33.            Load frmDeli32.ssrItems(Counter)

    34.            frmDeli32.ssrItems(Counter).Move frmDeli32.ssrItems(Counter - 1).Left + frmDeli32.ssrItems(Counter - 1).Width, frmDeli32.ssrItems(Counter - 1).Top

    35.          End If

    36.          gItems(Counter) = IIf(TempDynaset.Fields("ISSUBCAT").Value & "" = "Y", "$$SC$$-", "") & TempDynaset.Fields("ITEM_CODE").Value

    37.          gItemsIncludeAsTopping(Counter) = TempDynaset.Fields("INCLUDEASTOPPING").Value

    38.          If Counter Mod 4 = 0 And Counter > 0 Then

    39.            frmDeli32.ssrItems(Counter).Move 0, frmDeli32.ssrItems(Counter - 1).Top + frmDeli32.ssrItems(Counter - 1).Height

    40.          End If

    41.          frmDeli32.ssrItems(Counter).Tag = TempDynaset.Fields("ASKFORHALFORWHOLETOPPINGS").Value

    42.          frmDeli32.ssrItems(Counter).Caption = TempDynaset.Fields("DESCRIPTION").Value

    43.          frmDeli32.ssrItems(Counter).BackColor = frmDeli32.ssrCategories(CategoryButtonIndex).BackColor

    44.          frmDeli32.ssrItems(Counter).Visible = True

    45.          frmDeli32.ssrItems(Counter).Enabled = True

    46.          IconFileName = GetIcon(TempDynaset.Fields("ICON"))

    47.          If IconFileName <> "" Then

    48.            frmDeli32.ssrItems(Counter).Picture = LoadPicture(IconFileName)

    49.            Kill IconFileName

    50.          Else

    51.            frmDeli32.ssrItems(Counter).Picture = Nothing

    52.          End If

    53.          frmDeli32.ssrItems(Counter).PictureDn = frmDeli32.ssrItems(Counter).Picture

    54.           TempDynaset.MoveNext

    55.       Next Counter

    56.       Call SetScrollAreas

    57.     End If

    58.   End If

    59. Done:

    60.   Set TempDynaset = DatabaseCloseDynaset

    61.   frmDeli32.Resizer1.Rebuild

    62.   frmDeli32.Resizer1.Refresh

    63.   Exit Sub

    64. ErrorHandler:

    65.   Call MsgBox("Error #" & Err.Number & ":  " & Err.Description, vbCritical + vbOKOnly, "Error in frmDeli32.LoadItems....")

    66.   Resume Done

    67. End Sub


  14. Feb 17th, 2006, 09:25 AM


    #14

    Re: Automation Error -2147417848 The object invoked has disconnected from its clients

    It’s hard to tell where the error might be raised in that rather large sub. May I suggest that you insert line numbers (yes, line numbers) on each line, if you don’t have it already download MZ-Tools which is a great add-in and that is able to (among many other things) insert (and remove) line numbers automatically into a Sub or Function. Now you can use the undocumented Erl function in your error handler to get the line number of the line that has raised the error. That way you have tracked down the exact line that causes the error, and that might help alot.


  15. Feb 17th, 2006, 09:35 AM


    #15

    tward is offline

    Thread Starter


    Hyperactive Member


    Re: Automation Error -2147417848 The object invoked has disconnected from its clients

    Thanks, I’ll give that a try!


  16. Feb 21st, 2006, 07:10 AM


    #16

    tward is offline

    Thread Starter


    Hyperactive Member


    Re: Automation Error -2147417848 The object invoked has disconnected from its clients

    Thanks, tracked it down to: frmDeli32.Resizer1.Rebuild


  17. Apr 1st, 2016, 10:42 AM


    #17

    ja25921 is offline


    New Member


    Re: Automation Error -2147417848 The object invoked has disconnected from its clients

    Quote Originally Posted by Joacim Andersson
    View Post

    I’ve had this error in the past, always on Win2000 (is that what you’re using). This error has many causes often related to some form of MS Office automation. Are you using any automation or do you use any of the Forms 2.0 objects, or maybe the Access Calender control MSCAL.OCX?

    My team and I had the same issue and struggled with it for years. We finally identified a fix: We first unregistered the MSCAL.OCX then re-registered. That took care of the problem.


  18. Apr 2nd, 2016, 07:02 AM


    #18

    Re: [RESOLVED] Automation Error -2147417848 The object invoked has disconnected from

    Please don’t wake up 10 year old threads.


  • Home
  • VBForums
  • Visual Basic
  • Visual Basic 6 and Earlier
  • [RESOLVED] Automation Error -2147417848 The object invoked has disconnected from its clients


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
  • BB code is On
  • Smilies are On
  • [IMG] code is On
  • [VIDEO] code is On
  • HTML code is Off

Forum Rules


Click Here to Expand Forum to Full Width

rizik32

0 / 0 / 0

Регистрация: 13.08.2018

Сообщений: 30

1

Ошибка при авторизации

21.08.2018, 10:33. Показов 2313. Ответов 16

Метки нет (Все метки)


Хочу настроить автоматическую авторизацию на сайте, не получается, т.к. выдает ошибку: «automation error
The object invoked has disconnected from its clients»

Если я убираю часть этого кода, то выдает вторую ошибку: «Method ‘document’ of object ‘IWebBrowser2’ failed»

Помогите, в чем проблема? в гугле яндексе получается все, а в ссылке на работе нет.

Код макроса:

Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Sub autoriz()
Dim ie As Object
 
Set ie = CreateObject("internetexplorer.application")
 
With ie
    .Visible = True
    .navigate "https://xxx.ru/xxx/xxx/authorization.php"
Do While .busy
    DoEvents
Loop
 
Do While .readystate <> 4 ' Здесь первая ошибка, если убираю это то вторую ошибку выдает
    DoEvents
Loop
 
 
Set searchtxt = .document.getelementbyID("user_nickname") ' здесь вторая ошибка
 
searchtxt.Value = "986697"
 
 
.document.forms(0).submit
 
Do While .busy
    DoEvents
Loop
 
Do While .readystate <> 4
    DoEvents
Loop
Set searchres = .document.getelementbyID("resultStats")
 
ThisWorkbook.Sheets(1).Range("a1") = searchres.innertext
    .Quit
End With
 
 
End Sub

Код формы авторизации:

HTML5
1
<input name="user_nickname" id="user_nickname" type="text" size="20" maxlength="64">

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



39 / 37 / 13

Регистрация: 08.10.2016

Сообщений: 171

22.08.2018, 08:50

2

Что в окне ie после navigate? Нет ли блокировок данных политиками ie? Возможно, необходимо сделать refresh страницы.

Цитата
Сообщение от rizik32
Посмотреть сообщение

https://xxx.ru/xxx/xxx/authorization.php

Я бы помог, наверное, только нужен реальный url.



0



0 / 0 / 0

Регистрация: 13.08.2018

Сообщений: 30

22.08.2018, 09:17

 [ТС]

3

URL это рабочий, поэтому перейти по нему все равно не получится, есть ли смысл в его предоставлении?

Добавлено через 19 минут
ji2n, ji2n, URL это рабочий, поэтому перейти по нему все равно не получится, есть ли смысл в его предоставлении?



0



ji2n

39 / 37 / 13

Регистрация: 08.10.2016

Сообщений: 171

22.08.2018, 09:45

4

Похоже, что каким-то образом ссылка ie теряет связь с объектом. Убедитесь, что ie not nothing, если всё-таки так, то
попробуйте выполнить

Visual Basic
1
 Set ie = CreateObject("Shell.Application").Windows(0)



0



rizik32

0 / 0 / 0

Регистрация: 13.08.2018

Сообщений: 30

22.08.2018, 11:30

 [ТС]

5

ji2n, спасибо, так открывает, но при visible если браузер закрыт ошибка, но это ладно,

теперь при определении инпута ошибку выдает Type Mismatch хотя ID верно прописан, подскажите что делать?

Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Sub autoriz()
Dim ie As Object
 
Set ie = CreateObject("Shell.Application").Windows(0)
 
With ie
    .Visible = True 'ошибка
    .navigate "https://xxx.ru/xxx/xxx/authorization.php"
Do While .busy
    DoEvents
Loop
 
Do While .readystate <> 4 
    DoEvents
Loop
 
 
Set searchtxt = .document.getelementbyID("user_nickname") ' ошибка type mismatch
searchtxt.Value = "986697"
 
 
.document.forms(0).submit



0



ji2n

39 / 37 / 13

Регистрация: 08.10.2016

Сообщений: 171

22.08.2018, 13:04

6

Вот посмотрите, сделал для Вас похожую для вашего кода задачу (код своей html Вы не дали):

Кликните здесь для просмотра всего текста

Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Sub autoriz()
  Dim SH As Object, oWin As Object, IE As Object
    'Dim ie As New InternetExplorer
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    IE.navigate "https://starper55plys.ru"
    Set IE = Nothing ' Обнуляем ссылку! (типа, связь пропала) !!!!!!!!!!!!
'Восстановим связь с Internet Explorer
'только нужное окно (экземпляр IE) должен быть один в памяти
'(иначе надо будет немного подправить код)
Set SH = CreateObject("Shell.Application")
  For Each oWin In SH.Windows
    If oWin.Name = "Internet Explorer" Then
       Set IE = oWin
        Exit For
    End If
  Next
  If Not IE Is Nothing Then
    MsgBox IE.Document.URL
    IE.Document.getElementById("s").Value = "986697"
    IE.Document.getElementById("searchsubmit").click
    Do While IE.readyState <> 4
    DoEvents
    Loop
  End If
'IE.Quit
End Sub



0



rizik32

0 / 0 / 0

Регистрация: 13.08.2018

Сообщений: 30

22.08.2018, 17:18

 [ТС]

7

ji2n, теперь ошибка «Method ‘Document’ of object ‘IWebBrowser2’ failed». С вашим сайтом получилось, на ядексе, гугле тоже работает, а на рабочей ссылке не получается… Можете еще помочь?

Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Sub autorizу()
  Dim SH As Object, oWin As Object, IE As Object
    'Dim ie As New InternetExplorer
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    IE.navigate "https://xxx.ru/xxx/xxx/authorization.php"
    Set IE = Nothing ' Обнуляем ссылку! (типа, связь пропала) !!!!!!!!!!!!
'Восстановим связь с Internet Explorer
'только нужное окно (экземпляр IE) должен быть один в памяти
'(иначе надо будет немного подправить код)
Set SH = CreateObject("Shell.Application")
  For Each oWin In SH.Windows
    If oWin.Name = "Internet Explorer" Then
       Set IE = oWin
        Exit For
    End If
  Next
  If Not IE Is Nothing Then
    MsgBox IE.Document.URL ' здесь ошибка
    IE.Document.getElementById("s").Value = "986697"
    IE.Document.getElementById("searchsubmit").Click
    Do While IE.readyState <> 4
    DoEvents
    Loop
  End If
'IE.Quit
End Sub



0



ji2n

39 / 37 / 13

Регистрация: 08.10.2016

Сообщений: 171

22.08.2018, 20:23

8

Цитата
Сообщение от rizik32
Посмотреть сообщение

IE.Document.getElementById(«s»).Value = «986697»
* * IE.Document.getElementById(«searchsubmit»).Click

тут id не напутали?
строки 22-24:

Visual Basic
1
2
3
    Do While IE.readyState <> 4
    DoEvents
    Loop

поставить после строки: 18

Visual Basic
1
If Not IE Is Nothing Then

Добавлено через 45 минут
Открыть диспетчер задач, поубивать все процессы IE!

Цитата
Сообщение от rizik32
Посмотреть сообщение

(экземпляр IE) должен быть один в памяти

Выполняли?

И запустить макрик с другой машины, лучше даже другой версии ОС, Офис итп. Я начинаю думать, что неполадки где-то в этом.



0



0 / 0 / 0

Регистрация: 13.08.2018

Сообщений: 30

22.08.2018, 22:29

 [ТС]

9

ji2n, завтра на работе попробую поменять строки и изменить id, его не менял потому что не дошел до него даже, через диспетчер не пробовал убить IE c другой машины тоже нет, но попробую, хотя не думаю что получится, т.к. работаем на удаленке, а там в целом все одинаково у всех. ОС и офис к сожалению поменять не получится…

Я изначально думал, что так как стоит система авторизации, то может поэтому не дает ввести, т.к. при открытии ссылки по центру экрана просто появляется два инпута логин, пароль, и кнопка регистрация, может из-за этого чего-то быть? нужен ли может код страницы если не получится?



0



ji2n

39 / 37 / 13

Регистрация: 08.10.2016

Сообщений: 171

23.08.2018, 08:23

10

Кстатьи, еще 1 вариант:

Кликните здесь для просмотра всего текста

Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
Sub autoriz()
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
URL = "https://xxx.ru/xxx/xxx/authorization.php"
Send = "?user_nickname=986697&submit=click"
ie.navigate URL & Send
Do While ie.readyState <> 4
    DoEvents
Loop
MsgBox "Гуд бай"
ie.Quit
End Sub

Цитата
Сообщение от ji2n
Посмотреть сообщение

Send = «?user_nickname=986697&submit=click»

или так

Visual Basic
1
send = "?user_nickname=986697&click"

Тоже в работающем примере:

Кликните здесь для просмотра всего текста

Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
Sub xz()
Dim ie As InternetExplorer
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
URL = "https://starper55plys.ru"
send = "?s=986697&submit=click" ' или send = "?s=986697&searchsubmit=click"
ie.navigate URL & send
Do While ie.readyState <> 4
    DoEvents
Loop
MsgBox "Гуд бай"
ie.Quit
End Sub



0



rizik32

0 / 0 / 0

Регистрация: 13.08.2018

Сообщений: 30

23.08.2018, 10:41

 [ТС]

11

ji2n, попробовал поставить строки 22-24 после 18 ошибка «Method ‘Document’ of object ‘IWebBrowser2’ failed» на строке

Visual Basic
1
ie.Document.getElementById("os_username").Value = "986697" ' id не перепутал, пробовал на другом сайте не получилось с user_nickname тоже не получается

При другом коде ошибка

Automation error
The object invoked has disconnected from its clients

Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
Sub autoriz()
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
URL = "https://xxx.ru/xxx/xxx/authorization.php"
Send = "?user_nickname=986697&submit=click"
ie.navigate URL & Send
Do While ie.readyState <> 4 ' ошибка
    DoEvents
Loop
MsgBox "Гуд бай"
ie.Quit
End Sub

Попробую на другом компе, отпишусь.



0



rizik32

0 / 0 / 0

Регистрация: 13.08.2018

Сообщений: 30

23.08.2018, 11:56

 [ТС]

13

ji2n, так тоже пробовал, хотел посмотреть что добавляется, в итоге ничего не добавляется, открываю вручную ссылку:

PHP
1
https://tc-dev0.xxx.ru/common/aaa/authorization.php?refadr=/projects/testing/sc180307_0000_testing_074_1/SiteMap.php

Далее ввожу логин и пароль нажимаю «Войти», ссылка меняется на:

PHP
1
https://tc-dev0.xxx.ru/common/aaa/authorization.php

Прогружается.

Потом попадаю на нужный сайт и ссылка становится:

PHP
1
https://tc-dev0.xxx.ru/projects/testing/sc180307_0000_testing_074_1/SiteMap.php

Добавлено через 15 минут
ji2n, на другой машине тоже не работает(((



0



39 / 37 / 13

Регистрация: 08.10.2016

Сообщений: 171

23.08.2018, 13:24

14

Всё-таки html код покажите.



0



rizik32

0 / 0 / 0

Регистрация: 13.08.2018

Сообщений: 30

23.08.2018, 13:49

 [ТС]

15

Вот код HTML для первого варианта там где user_nickname, где os_username отличается только ссылка.

HTML5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<html> 
  <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
    <link href="https://vote2.xxx.ru:443/common/aaa/style.css" rel="stylesheet" type="text/css">
    
    
    <title>Авторизация</title>
    <script language="JavaScript" type="text/javascript">
    <!--
    function jtrim(inputString) {
       if (typeof inputString != "string"){
             return inputString; 
       };
       var retValue = inputString;
       var ch = retValue.substring(0, 1);
       while (ch == " "){
         retValue = retValue.substring(1, retValue.length);
         ch = retValue.substring(0, 1);
       };
       ch = retValue.substring(retValue.length-1, retValue.length);
       while (ch==" "){
         retValue = retValue.substring(0, retValue.length-1);
         ch = retValue.substring(retValue.length-1, retValue.length);
       };
       while (retValue.indexOf("  ") != -1){
         retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length);
       };
       return retValue;
    }; 
 
    function checkform(){
      if(jtrim(document.forms.authform.user_nickname.value).length==0){
        alert("Необходимо заполнить поле "Имя".");
        document.forms.authform.user_nickname.focus();
        return false;   
      };
      if(jtrim(document.forms.authform.user_password.value).length==0){
        alert("Необходимо заполнить поле "Пароль".");
        document.forms.authform.user_password.focus();
        return false;   
      };
  
      return true;
    };
    -->
    </script>
  </head>
  <body>
    <table width="100%" height="100%" cellspacing="5" cellpadding="5">
      <tr width="100%" height="50%">
        <td colspan="2">&nbsp;</td>
      </tr>
    <form id="authform" method="POST" action="authorization.php" onsubmit="return checkform();"><tr><td width="50%" align="right" class="fname">Имя:&nbsp;</td><td width="50%"><input type="text" id="user_nickname" name="user_nickname" maxlength="64" size="20"></td></tr><tr><td width="50%" align="right" class="fname">Пароль:&nbsp;</td><td width="50%"><input type="password" name="user_password" maxlength="64" size="20"></td></tr><tr><td colspan="2" align="center"><input type="submit" value="Регистрация"></td></tr><input name="refadr" type="hidden" value="https://vote2.xxx.ru:443/xxx/sc130620_0000_xxx_xxx/admin/statbyoper_light.php"></form>  
      <tr width="100%" height="50%">
        <td colspan="2">&nbsp;</td>
      </tr>
    </table>    
  </body> 
</html>



0



39 / 37 / 13

Регистрация: 08.10.2016

Сообщений: 171

23.08.2018, 15:19

16

Мистика какая-то.



0



0 / 0 / 0

Регистрация: 13.08.2018

Сообщений: 30

23.08.2018, 17:48

 [ТС]

17

ji2n, вот и я уже мучаюсь третью неделю, а что такое не могу понять, поэтому решил сюда обратиться.



0



IT_Exp

Эксперт

87844 / 49110 / 22898

Регистрация: 17.06.2006

Сообщений: 92,604

23.08.2018, 17:48

17

Понравилась статья? Поделить с друзьями:
  • Automation error library not registered vba
  • Automation error library not registered 2147319779
  • Automation error 2147417848
  • Automatic registration failed at join phase exit code unknown hresult error code 0x801c001d
  • Automake error no makefile am found for any configure output