EDIT: Perhaps, this is a better question. Is there a way to know if the parapgraph read has actually been deleted with Tracked Changes *ON*?
Hi
I am travessing a document using vba looking for paragraphs between certain headings. Now, for some documents the track changes is switched-on and there are *deleted* heading paragraphs in between normal text. The vba falls over when it gets deleted tracked changes paragraphs (I don't understand why it actually reads deleted paragraphs).
So, is there a way for me to accept trackedchanges, search between certain headings, extract text to another document and then restore tracked changes? Possibly not but I thought I would just ask.
Thanks.
Robie
Accept TC, do somethings, restore TC
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Accept TC, do somethings, restore TC
You can hide markup temporarily using
then show them again later using
Code: Select all
With ActiveWindow.View
.ShowRevisionsAndComments = False
.RevisionsView = wdRevisionsViewFinal
End With
Code: Select all
With ActiveWindow.View
.ShowRevisionsAndComments = True
.RevisionsView = wdRevisionsViewFinal
End With
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 656
- Joined: 18 Feb 2010, 14:26
Re: Accept TC, do somethings, restore TC
Thanks Hans but that still doesn't fix it. :-(HansV wrote:You can hide markup temporarily using
then show them again later usingCode: Select all
With ActiveWindow.View .ShowRevisionsAndComments = False .RevisionsView = wdRevisionsViewFinal End With
Code: Select all
With ActiveWindow.View .ShowRevisionsAndComments = True .RevisionsView = wdRevisionsViewFinal End With
It seems I am still getting the deleted paragraphs either using selection or range.
I am now thinking of just taking the content of the activedocument and copying to another document, remove tracked changes, process it and then delete it. Thus keeping the original intact.
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Accept TC, do somethings, restore TC
How do you traverse the document? When I use a loop like this:
I don't get paragraphs marked for deletion if I display "Final"...
Code: Select all
Dim par As Paragraph
For Each par In ActiveDocument.Paragraphs
Debug.Print par.Range.Words(1)
Next par
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 656
- Joined: 18 Feb 2010, 14:26
Re: Accept TC, do somethings, restore TC
That's different. I am expanding a range or selection a paragraph at a time.HansV wrote:How do you traverse the document? When I use a loop like this:
I don't get paragraphs marked for deletion if I display "Final"...Code: Select all
Dim par As Paragraph For Each par In ActiveDocument.Paragraphs Debug.Print par.Range.Words(1) Next par
Perhaps, I should try your method.
-
- Administrator
- Posts: 12618
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: Accept TC, do somethings, restore TC
If you're not making changes to the document in between then you could try
Code: Select all
Sub AcceptRevisionsAndUndo()
ActiveDocument.AcceptAllRevisions
' Do stuff here.
ActiveDocument.Undo
End Sub
StuartR
-
- 5StarLounger
- Posts: 656
- Joined: 18 Feb 2010, 14:26
Re: Accept TC, do somethings, restore TC
Thanks Stuart, that a grand idea.StuartR wrote:If you're not making changes to the document in between then you could try
Code: Select all
Sub AcceptRevisionsAndUndo() ActiveDocument.AcceptAllRevisions ' Do stuff here. ActiveDocument.Undo End Sub
All I am doing is *reading* from this document - no changes whatsoever. I guess this should work. I will try it out.
-
- 5StarLounger
- Posts: 656
- Joined: 18 Feb 2010, 14:26
Re: Accept TC, do somethings, restore TC
That was an inspired idea Stuart. It works wonderfully well.StuartR wrote:If you're not making changes to the document in between then you could try
Code: Select all
Sub AcceptRevisionsAndUndo() ActiveDocument.AcceptAllRevisions ' Do stuff here. ActiveDocument.Undo End Sub
Thank you so much.