It doesn't work :dunno
should I do something else, apart from copy and paste that code after "Next" ?
thanks
Printable View
It doesn't work :dunno
should I do something else, apart from copy and paste that code after "Next" ?
thanks
Well, given that you reckoned the macro you quoted worked OK for what it was coded to do, I didn't bother looking at your attachment, since all that was needed was to add two more F/R operations of the same kind to the code. What I now find is that your attachment has a separate paragraph for each line, rather than manual line breaks. This goes back to what I said before. Remember how you said my code "works perfectly"? That was for code that looked for line breaks, not paragraph breaks. And that's what one gets in Word if one copies & pastes the strings you'd posted here into a document. Remember too how, when I said "The fact is every line is NOT a paragraph - they're simply lines separated by manual line breaks within the same paragraph", you came back with:
Well, if that was true the code that you said "works perfectly" wouldn't have worked then and won't work now, even without the new code. So, either the code worked before, and you had line breaks then, or it never worked at all. There is no in-between.Quote:
in my document there's no Shift+Enter line breaks, only "paragraph breaks"..."
Now that I have looked at your attachment, I can see that making the macro work with what you now have means replacing every instance of ^l in the code with ^13. Then and only then will it work.
Thanks! only one problem left: when I run the 3 macros one after another, at the end it's ok except that there's a paragraph break (ie. a blank line) just before \trad... (a normal paragraph break at the end of the preceding line of code, plus another one below, which makes like a blank line in the document) do you know why and how to change that?
Here are the 3 macros:
Thanks a lot!
Code:Sub XmlToLp1SupprimerChampsInutiles()
Application.ScreenUpdating = False
Dim strTags As String, i As Long
strTags = "identifiant|identifiant,image|lieu," & _
"enqueteur|contexte,DonneesMorpho|DonneesSynt," & _
"type|DateMiseAJour"
With ActiveDocument.Range.Find
.ClearFormatting
.Replacement.ClearFormatting
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchWildcards = True
.Replacement.Text = ""
For i = 0 To UBound(Split(strTags, ","))
.Text = "\<" & Split(Split(strTags, ",")(i), "|")(0) & "\>*\</" & Split(Split(strTags, ",")(i), "|")(1) & "\>^13"
.Execute Replace:=wdReplaceAll
.Text = "^13\<" & Split(Split(strTags, ",")(i), "|")(0) & "\>*\</" & Split(Split(strTags, ",")(i), "|")(1) & "\>"
.Execute Replace:=wdReplaceAll
Next
.Text = "\<item id=[!\>]@\>"
.Execute Replace:=wdReplaceAll
.Text = "\</item\>"
.Execute Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True
End Sub
---------------------------
Sub XmlToLp2SupprimerTagsFermantsEtConvertirMarqueurs()
Application.ScreenUpdating = False
Dim strTags As String, i As Long
strTags = "FichierSon|sfx,informateur|xinfor,BretonLocal|xbrloc," & _
"phon|xfon,BretonStandard|xv,TraducFr|xtrad,TraducLitt|lt,nt|nt"
With ActiveDocument.Range.Find
.ClearFormatting
.Replacement.ClearFormatting
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchWildcards = True
For i = 0 To UBound(Split(strTags, ","))
.Text = "(\<)(" & Split(Split(strTags, ",")(i), "|")(0) & "\>)(*)\1/\2"
.Replacement.Text = "^92" & Split(Split(strTags, ",")(i), "|")(1) & " \3"
.Execute Replace:=wdReplaceAll
Next
End With
Application.ScreenUpdating = True
End Sub
-----------------------------------------------------
Sub XmlToLp3MettreMarqueursDansOrdreLp()
Application.ScreenUpdating = False
Dim strTags As String, i As Long
strTags = "sfx|xv,xinfor|xfon"
With ActiveDocument.Range.Find
.ClearFormatting
.Replacement.ClearFormatting
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchWildcards = True
.Text = "^13"
.Replacement.Text = "^13^p"
.Execute Replace:=wdReplaceAll
For i = 0 To UBound(Split(strTags, ","))
.Text = "(\\" & Split(Split(strTags, ",")(i), "|")(0) & "*)(\\" & Split(Split(strTags, ",")(i), "|")(1) & "*^13)"
.Replacement.Text = "\2\1"
.Execute Replace:=wdReplaceAll
Next
.Text = "^13^13"
.Replacement.Text = "^p"
.Execute Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True
End Sub
I can see that you're using different code to what I've advised, for both XmlToLp1SupprimerChampsInutiles and XmlToLp3MettreMarqueursDansOrdreLp. I'll leave it to you to figure out which sub is causing the problem, why and how to fix it.
Where is it different??? I've changed ^l to ^13 as you told, I've copied and pasted your code after "Next" as you told...
apart from that, what is different? :dunno
Well, I did not suggest the changes you made to the XmlToLp3MettreMarqueursDansOrdreLp macro - I suggested changing only the XmlToLp1SupprimerChampsInutiles macro. And, where I suggested changing the XmlToLp1SupprimerChampsInutiles macro, you've deleted two instances of ^l from the additional code instead of changing them to ^13.
You make it very hard for anyone to help you solve your problems!!!
sh*te... I did "find/replace" in the Macros' page in Word, I didn't know it would change all occurrences at the same time, I thought it would only change them in the Macro I was working on :( I thought the separation lines between the macros would stop it :(Quote:
Well, I did not suggest the changes you made to the XmlToLp3MettreMarqueursDansOrdreLp macro - I suggested changing only the XmlToLp1SupprimerChampsInutiles macro.
Yes because I noticed my XML code, when copied and pasted in Word, had no line jumps but only paragraph jumps!Quote:
And, where I suggested changing the XmlToLp1SupprimerChampsInutiles macro, you've deleted two instances of ^l from the additional code instead of changing them to ^13.
I see the problem now... looks like sometimes when I copy and paste my XML document to a word document, each line ends with a paragraph jump ; and other times, they end with a line jump. I didn't notice that before. That's why we had problems with the line jumps and paragraph jumps earlier. The problem is that I open my XML stuff with different software to make different tasks: Notepad, Notepad++, XML Notepad 2007 and Word. I guess some of them make a line jump when I push Enter, and others make a paragraph jump, and I didn't verify that ; that's why your macros sometimes worked and other times they didn't work :(
Thanks again and sorry again...
OK, so you're importing text that could be using line breaks, or it could be using paragraph breaks. That's no big deal - it's quite easy to cater for both. But why are you using three separate macros instead of doing the whole process with just one? Unless you're getting data that comes in the different stages for what each macro does, the only reason I can see for that is that you never gave a single specification of what you were starting with and what you were trying to achieve.