#1
|
|||
|
|||
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. |
#2
|
||||
|
||||
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] |
#3
|
|||
|
|||
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 |
#4
|
||||
|
||||
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] |
#5
|
|||
|
|||
Emphatically agree. Run it 1x. Then make your own comment but don't press the blue arrow. Then run it 1x more.
|
#6
|
||||
|
||||
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 |
#7
|
|||
|
|||
Quote:
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
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 |
VB Code in Excel Active worksheet | shakilhyd | Excel | 2 | 05-17-2010 07:50 AM |