Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 03-20-2019, 06:06 PM
mktate mktate is offline Automation Error - the object invoked has disconnected from its clients Windows 10 Automation Error - the object invoked has disconnected from its clients Office 2010 64bit
Novice
Automation Error - the object invoked has disconnected from its clients
 
Join Date: Dec 2015
Posts: 26
mktate is on a distinguished road
Default Here is the Code - unable to locate an issue

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
Reply With Quote
 

Tags
vba automation error



Similar Threads
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
Automation Error - the object invoked has disconnected from its clients Automation error Unknown error" message once they open the Excel file hlina Excel 1 10-08-2013 09:14 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:21 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft