![]() |
|
#1
|
|||
|
|||
![]()
I have a Word Userform with different command buttons that have worked for over a year - these buttons are used to generate various sets of Word documents. Today when I click on any command button, I get a VBA Automation error message that says "the object invoked has disconnected from its clients." Thereafter, I lose quick access toolbar buttons (the close button for example) and then after using file/close to close any open files, I am unable to completely close Word - it says a dialog box is still open although there are no dialog boxes open (alt-tab and there is nothing open except Word). I have restarted, used the Windows compatibility troubleshooter, reinstalled the normal template, to no avail. Any help is appreciated.
|
#2
|
||||
|
||||
![]()
What is the code that is being run when you click on the command button?
If you put a breakpoint in the start of that code, you will be able to step through your code to find the problem.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
![]()
Here is the code. Note that I was unsuccessful in finding a line of code with an issue after adding a breakpoint at the Documents.Add. I am sure the code could be written better but the Code has worked for over a year until today. I really appreciate the reply!
Private Sub cmdMemo_Click() On Error Resume Next Documents.Add "path to form/word template" Dim oDoc As Document For Each oDoc In Documents oDoc.Activate Set oVars = ActiveDocument.Variables Call FillVariables Call FillVariables2 If Me.cboNochildren.Value = "0" Then Noofchild0 If Me.cboNochildren.Value = "1" Then Noofchild1 If Me.cboNochildren.Value = "2" Then Noofchild2 If Me.cboNochildren.Value = "3" Then Noofchild3 If Me.cboNochildren.Value = "4" Then Noofchild4 ActiveDocument.Fields.Update If ActiveDocument.AttachedTemplate.Name <> "Data Set.DOTM" Then ActiveDocument.Fields.Unlink Dim rngStory As Word.Range Dim oShape As Word.Shape For Each rngStory In ActiveDocument.StoryRanges If rngStory.ShapeRange.Count > 0 Then For Each oShape In rngStory.ShapeRange If oShape.TextFrame.HasText Then oShape.TextFrame.TextRange.Fields.Update oShape.TextFrame.TextRange.Fields.Unlink End If Next oShape End If Set rngStory = rngStory.NextStoryRange Next rngStory ActiveDocument.Content.NoProofing = False Next oDoc Set oVars = Nothing Me.Hide End Sub |
![]() |
Tags |
vba automation error |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
I have Error at File System Object: Cant find object or lib | johndrew | Word VBA | 3 | 07-05-2018 08:46 PM |
set row object variable error | CLoos | Excel Programming | 6 | 03-10-2017 04:48 PM |
Contacts disconnected | george3095 | Outlook | 0 | 10-14-2014 07:15 AM |
VBA to identify how Word was invoked | Sorcerer13 | Word VBA | 7 | 04-24-2014 11:15 AM |
![]() |
hlina | Excel | 1 | 10-08-2013 09:14 PM |