Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #14  
Old 05-24-2021, 11:36 AM
jalve jalve is offline Duplicate paragraphs except in tables Windows 10 Duplicate paragraphs except in tables Office 2013
Novice
Duplicate paragraphs except in tables
 
Join Date: Mar 2020
Posts: 12
jalve is on a distinguished road
Default

I am not running them more than once on a file. Sorry, I can't post the document because of copyright issues.



The document starts with a table of contents, followed by a table of figures, followed by a table of tables. Then there is a page break, and the title of the document, followed by the body of the document. The first sign that something is not right is in the table of contents, which happens to have some code visible like this:

TOC \o "1-3" \h \z \u

This is in the hidden non-editable first line of the table of contents.



Other than that, the styles appear to be okay.


Only after running the second macro to extract the translated text the styles are applied to the wrong paragraphs.



Here's the macro I use before translation:




Sub PrepareForTranslation()
'
' PrepareForTranslation Macro
'

'Graham Mayor - Graham Mayor - Home Page - Last updated - 095 Mar 2020
'Modified by Jukka Alve - Last updated 2021-05-24

Dim oSource As Document, oTarget As Document
Dim oRng As Range
Dim oPara As Paragraph
Dim oCC1 As ContentControl, oCC2 As ContentControl
ActiveDocument.Range.ListFormat.ConvertNumbersToTe xt
Set oSource = ActiveDocument
oSource.Save
If oSource.Path = "" Then GoTo lbl_Exit
Set oTarget = Documents.Add(oSource.FullName)
oTarget.Range.Text = vbCr
For Each oPara In oSource.Paragraphs
If oPara.Range.Information(wdWithInTable) = False And Len(oPara.Range) > 1 Then
'oPara.Range.Copy
Set oRng = oTarget.Range
oRng.Collapse 0

Set oCC1 = oTarget.ContentControls.Add(wdContentControlRichTe xt, oRng)
oCC1.Range.FormattedText = oPara.Range.FormattedText
oCC1.Range.Font.ColorIndex = wdBlue
oCC1.Range.Font.Hidden = True
oCC1.Appearance = wdContentControlHidden
oCC1.LockContentControl = True
oCC1.LockContents = True


Set oRng = oTarget.Range
oRng.Collapse 0

Set oCC2 = oTarget.ContentControls.Add(wdContentControlRichTe xt, oRng)
oCC2.Range.FormattedText = oPara.Range.FormattedText
oCC2.LockContentControl = True
End If
DoEvents
Next oPara
oTarget.Save
oTarget.Paragraphs(1).Range.Delete
lbl_Exit:
Set oSource = Nothing
Set oTarget = Nothing
Set oRng = Nothing
Set oPara = Nothing
Exit Sub
End Sub




The one I use after translation is identical to Graham's Macro2.



Reply With Quote
 

Tags
4605, copy/paste paragraph, tables



Similar Threads
Thread Thread Starter Forum Replies Last Post
Duplicate paragraphs except in tables delete 1 or 2 adjacent duplicate paragraphs, macro moorea21 Word 4 11-01-2018 12:53 PM
Duplicate paragraphs except in tables How to find duplicate phrases/paragraphs in a long document iamgator Word VBA 5 12-27-2016 01:34 AM
Duplicate paragraphs except in tables Using VB.Net 2010 I cannot duplicate tables in the correct place AaaTeX Word Tables 3 08-03-2014 07:00 PM
Show & hide paragraphs, parts of tables, etc Preloader Word 2 10-19-2013 02:37 PM
Duplicate paragraphs except in tables add the functionality to show & hide paragraphs, parts of tables, etc pgwolfe Word 3 09-24-2013 07:58 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:42 AM.


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