Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-17-2022, 07:36 AM
BrianHoard BrianHoard is offline Comments in Word causing script to crash Windows 10 Comments in Word causing script to crash Office 2019
Advanced Beginner
Comments in Word causing script to crash
 
Join Date: Jul 2022
Location: Haymarket, VA USA
Posts: 85
BrianHoard is on a distinguished road
Default Comments in Word causing script to crash

I have reduced my script and the attached Word doc to the bare minimum to reproduce this problem.

Starting with a document with a single word and 1 endnote, the following code runs fine:
Code:
ActiveDocument.Range.EndnoteOptions.numberStyle = 0
But, if we add a Word Comment using Review > Comments > New Comment, then run the script, I get the following error:
Run-time error '4605':
This method or property is not available because the object refers to a footnote, endnote, or comment.

In troubleshooting this, sometimes I will not get the error. But if I delete the comment, and then add a new one again, it will give the error again.

I just did another test without any endnotes, and get the error when a comment is added to just a single word in the document.



This is my first experience dealing with Comments, so not sure yet how to work around them in my code.
Attached Files
File Type: docx endnoteComment.docx (19.7 KB, 3 views)
Reply With Quote
  #2  
Old 09-18-2022, 12:31 AM
Guessed's Avatar
Guessed Guessed is offline Comments in Word causing script to crash Windows 10 Comments in Word causing script to crash Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
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

It appears that the line fails IF your cursor is sitting in a Comment at the time.

Looking at the line of code I would have to say that it should be independent of where the cursor happens to be sitting but that won't be a soapbox worth standing on.

Just add a line in front of it that selects something in the body of the document and move along - some things are not worth losing sleep over.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 09-18-2022, 07:33 AM
BrianHoard BrianHoard is offline Comments in Word causing script to crash Windows 10 Comments in Word causing script to crash Office 2019
Advanced Beginner
Comments in Word causing script to crash
 
Join Date: Jul 2022
Location: Haymarket, VA USA
Posts: 85
BrianHoard is on a distinguished road
Default

Thank you for the help. I see what you mean, even in Word, the Footnotes(Endnotes) option group in the ribbon gets grayed out when comments are active.
I see I can make the document active using:
Code:
Selection.HomeKey Unit:=wdStory
Not sure how to put the cursor back where it was before my script ran, but this will get the job done.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
iCloud Outlook Add In is causing Outlook 2021 to crash and got disabled andrease Outlook 2 08-25-2022 12:42 AM
Comments in Word causing script to crash Word 97, What's Causing These Document to Look DIfferent dw85745 Word 3 01-08-2022 07:48 AM
Comments in Word causing script to crash Template causing slow load of Word plakerl Word 3 06-15-2011 05:40 PM
Word Crash on Quit masomenos Word 2 11-09-2010 12:35 AM
Comments in Word causing script to crash lost drawing toolbar causing Word to crash manyrains Drawing and Graphics 1 11-07-2009 12:27 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:25 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