Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-12-2022, 01:42 PM
bronco9588 bronco9588 is offline Error Code when Running Macro with active comment Windows 10 Error Code when Running Macro with active comment Office 2019
Novice
Error Code when Running Macro with active comment
 
Join Date: Dec 2022
Posts: 4
bronco9588 is on a distinguished road
Default Error Code when Running Macro with active comment

Thanks in advanced.



I have a word document template that is designed to be sent from an author to a peer reviewer and back to the original author. During the peer review process it is normal and expected that the reviewer would insert comments. During commenting, you need to post the comment to make another comment. When I accidentally "forget" to post the last comment and run the macro, I get an error code:

4605 "This method or property is not available because comment card is selected in pane."

or if I have my cursor selected to reply to a preexisting comment, I get the following error code:

5825 "Object has been deleted."

In both cases the problem appears to be that I have an active comment and there the active document is not the actual document. What is the best way to post the last comment text and return to the document body before running the macro?

Something like:

If ActiveDocument.Comment is Open
Post comments
ActiveDocument.Sections(1).Range.Select
End If

My apologies for poor programming.
Reply With Quote
  #2  
Old 12-12-2022, 02:01 PM
macropod's Avatar
macropod macropod is offline Error Code when Running Macro with active comment Windows 10 Error Code when Running Macro with active comment Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Without seeing your actual code, no-one can tell you what needs changing to get the correct result.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 12-12-2022, 02:11 PM
bronco9588 bronco9588 is offline Error Code when Running Macro with active comment Windows 10 Error Code when Running Macro with active comment Office 2019
Novice
Error Code when Running Macro with active comment
 
Join Date: Dec 2022
Posts: 4
bronco9588 is on a distinguished road
Default

So here is an example. I put the macro into a link on the quick reference toolbar and run 1x. I then click on reply in the comment. I then click on my macro link.

You could also add a comment and run the macro without pressing the blue arrow on comment.

Code:
Sub Macro1()
    Selection.TypeText Text:="Test Document"
    Selection.Comments.Add Range:=Selection.Range, Text:="Hi There"
    Selection.WholeStory
    Selection.MoveLeft Unit:=wdCharacter, Count:=1
End Sub
I would like to macro to post the active comment and then return to the beginning of the document. Of note, it doesn't look like you can select macros from within a comment.
Reply With Quote
  #4  
Old 12-12-2022, 03:14 PM
macropod's Avatar
macropod macropod is offline Error Code when Running Macro with active comment Windows 10 Error Code when Running Macro with active comment Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

It doesn't seem to me the code you've just posted has anything to do with what you described in post #1.

Repeatedly running the code you posted merely inserts the same text and comment multiple times.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 12-12-2022, 03:47 PM
bronco9588 bronco9588 is offline Error Code when Running Macro with active comment Windows 10 Error Code when Running Macro with active comment Office 2019
Novice
Error Code when Running Macro with active comment
 
Join Date: Dec 2022
Posts: 4
bronco9588 is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
It doesn't seem to me the code you've just posted has anything to do with what you described in post #1.

Repeatedly running the code you posted merely inserts the same text and comment multiple times.
Emphatically agree. Run it 1x. Then make your own comment but don't press the blue arrow. Then run it 1x more.
Reply With Quote
  #6  
Old 12-12-2022, 04:40 PM
Guessed's Avatar
Guessed Guessed is offline Error Code when Running Macro with active comment Windows 10 Error Code when Running Macro with active comment 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

I don't have a solution for you but will add a little explanation for others to think about.

There is a new behaviour of comments which appears in Word 365 but not in earlier versions. Now it appears that you can 'add' a comment via the GUI but until it is posted by clicking the button or pressing Ctrl-Enter then Word stores it in some intermediate mode which isn't a comment (according to VBA) although it shows alongside other comments in the comments pane. If you then try to add another new comment, the cursor returns to the un-submitted comment and won't allow new comments until you either post or delete that one. This behaviour is very annoying and not how the earlier versions of Word handled comments. I presume this is the problem that bronco9588 is trying to solve.

Recording a macro of adding comments shows that a comment gets 'added' only after it is posted and an unposted comment doesn't get recorded as an action. The unposted comment appears with the other comments but doesn't get included in the document's comment collection in VBA.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #7  
Old 12-12-2022, 06:32 PM
bronco9588 bronco9588 is offline Error Code when Running Macro with active comment Windows 10 Error Code when Running Macro with active comment Office 2019
Novice
Error Code when Running Macro with active comment
 
Join Date: Dec 2022
Posts: 4
bronco9588 is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
I don't have a solution for you but will add a little explanation for others to think about.

There is a new behaviour of comments which appears in Word 365 but not in earlier versions. Now it appears that you can 'add' a comment via the GUI but until it is posted by clicking the button or pressing Ctrl-Enter then Word stores it in some intermediate mode which isn't a comment (according to VBA) although it shows alongside other comments in the comments pane. If you then try to add another new comment, the cursor returns to the un-submitted comment and won't allow new comments until you either post or delete that one. This behaviour is very annoying and not how the earlier versions of Word handled comments. I presume this is the problem that bronco9588 is trying to solve.

Recording a macro of adding comments shows that a comment gets 'added' only after it is posted and an unposted comment doesn't get recorded as an action. The unposted comment appears with the other comments but doesn't get included in the document's comment collection in VBA.
Yes, that is spot on. What I would like my macro to do is post that comment and return to the body of my document so the rest of my macros can run.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Code when Running Macro with active comment Change active cell after running macro in active cell via selection change Peterson Excel Programming 3 03-07-2021 12:19 PM
Error with macro to delete starting #) [code included] puff Word VBA 1 04-18-2018 03:49 PM
VBA Code for Printing Active worksheet .. LearnerExcel Excel Programming 1 02-11-2018 01:37 AM
Error 5941 when running my macro to auto populate fields throughout the word doc VBAnovice1 Word VBA 2 05-26-2015 01:35 AM
Error Code when Running Macro with active comment VB Code in Excel Active worksheet shakilhyd Excel 2 05-17-2010 07:50 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:41 AM.


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