Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-23-2021, 08:30 AM
letcall letcall is offline Userform button: the object invoked has disconnected from its clients Windows 10 Userform button: the object invoked has disconnected from its clients Office 2019
Novice
Userform button: the object invoked has disconnected from its clients
 
Join Date: Aug 2021
Posts: 2
letcall is on a distinguished road
Default Userform button: the object invoked has disconnected from its clients

We recently upgraded our version of Office (subscription plan) and now our user form buttons that call a sub routine, no longer work.



Here is a sample of the code. When the Beta sub is called, the error is displayed and you have to kill the Word session using Task Manager to exit. We have a similar issue with Excel so it seems to be an Office issue.

Code:
Private Sub cmdCancel_Click()
End
End Sub

Private Sub cmdYes_Click()
If OptionButton1 Then Call Beta
If OptionButton2 Then Call Internal

End Sub

Sub Beta()
  Unload frmBetaInternal

  With Selection
    .HomeKey Unit:=wdStory
    .Find.ClearFormatting
    .Find.Replacement.ClearFormatting
    End With
    With Selection.Find
        .Text = "Contents"
        .Forward = True
        .Wrap = wdFindContinue
    End With
    Selection.Find.Execute
    
    Selection.MoveLeft Unit:=wdCharacter, Count:=3
    Application.Templates(ActiveDocument.AttachedTemplate.FullName). _
                BuildingBlockEntries("Disclaimer").Insert Where:=Selection.Range, RichText:=True
   Selection.HomeKey Unit:=wdStory

'Insert draft watermark
Dim oSection As Section
Dim oHeader As HeaderFooter
Dim oRng As Range
For Each oSection In ActiveDocument.Sections
    For Each oHeader In oSection.Headers
        Set oRng = oHeader.Range
        oRng.Collapse wdCollapseEnd
        Application.Templates(ActiveDocument.AttachedTemplate.FullName). _
                BuildingBlockEntries("DraftWatermark").Insert Where:=oRng, _
                                                             RichText:=True
    Next oHeader
Next oSection

End Sub
Any advice on what to check?
Reply With Quote
  #2  
Old 08-23-2021, 04:26 PM
Guessed's Avatar
Guessed Guessed is offline Userform button: the object invoked has disconnected from its clients Windows 10 Userform button: the object invoked has disconnected from its clients Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,974
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Which line is the error occurring on? That will make it easier to diagnose.

My observations are:
1. It is unusual to unload the userform and then expect the rest of the code to proceed since that code is inside the userform. I would recommend you remove that line from the Beta macro and put it at the end of the cmdYes_Click macro. Or better still, put it in the macro that called the userform in the first place. I use Me.Hide at the end of macros when I want to get rid of the userform. This allows the code to run to completion.
2. Application.Templates(ActiveDocument.AttachedTempl ate.FullName). is overly indirect. Try this instead ActiveDocument.AttachedTemplate.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 08-25-2021, 07:58 AM
letcall letcall is offline Userform button: the object invoked has disconnected from its clients Windows 10 Userform button: the object invoked has disconnected from its clients Office 2019
Novice
Userform button: the object invoked has disconnected from its clients
 
Join Date: Aug 2021
Posts: 2
letcall is on a distinguished road
Default Resolution, somewhat...

So it turns out that we had a Beta channel Office 365 version that was causing the issue. It does not have any to do with the VBA code! Apparently, there is a registry entry that gets corrupted and by rolling back to a GA version (2106), the issue goes away.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Automation Error - the object invoked has disconnected from its clients mktate Word VBA 2 03-20-2019 06:06 PM
Executing a userform with a command button spc94 Word VBA 2 06-24-2015 10:08 PM
VBA Code in a UserForm module to delete a Command Button which opens the userform Simoninparis Word VBA 2 09-21-2014 03:50 AM
Command button to show userform suddenly stopped working jpb103 Word VBA 0 05-22-2014 06:05 AM
Word doc bug when closing from userform command button click macro Joe Patrick Word 1 07-05-2011 08:53 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:17 PM.


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