Hello !
I know very well that this is a forum for Access questions. Or, at least, related to Access. But also I know that here are very skilled programers. Maybe someone will be able to help me with this problem.
 that this is a forum for Access questions. Or, at least, related to Access. But also I know that here are very skilled programers. Maybe someone will be able to help me with this problem.
@Moderators
No offense if you will decide to remove this thread.
But I hope to do this after few weeks. Thank you.
So, my problem(s).
I need to copy some (many) articles from the www and to turn it into Word document. Done. The Copy-Paste feature work great
I use (in Word) this code in order to "clean" the text:
	
	
	
		
The code do a good job but the last Do-Loop never end because at the end of document Word insert a Chr(13).
So my code will find forever the string Chr(13) & Chr(13)
I can survive with this (CTRL+Break) but the question remain:
How can I test that I am at the end of document ?
The main unsolved problem is that Word, after I run the code, still not understand where a paragraph start and where is ended (do a try with something copied from www).
So, I waste a lot of time in order to apply styles to certain paragraphs.
Can you help me ?
Thank you !
 I know very well
 that this is a forum for Access questions. Or, at least, related to Access. But also I know that here are very skilled programers. Maybe someone will be able to help me with this problem.
 that this is a forum for Access questions. Or, at least, related to Access. But also I know that here are very skilled programers. Maybe someone will be able to help me with this problem.@Moderators
No offense if you will decide to remove this thread.
But I hope to do this after few weeks. Thank you.
So, my problem(s).
I need to copy some (many) articles from the www and to turn it into Word document. Done. The Copy-Paste feature work great

I use (in Word) this code in order to "clean" the text:
		Code:
	
	
	Option Explicit
Sub UsualReplacements()
Dim LoopsCount As Long
    LoopsCount = 0
Dim FindWhat As String, ReplaceWith As String
'Manual line break -> Chr(13)
    FindWhat = "^l"
    ReplaceWith = Chr(13)
        Selection.HomeKey Unit:=wdStory
        Do
            LoopsCount = LoopsCount + 1
        Loop While Replacements(FindWhat, ReplaceWith)
    
    FindWhat = " " & Chr(13)
    ReplaceWith = Chr(13)
        Selection.HomeKey Unit:=wdStory
        Do
            LoopsCount = LoopsCount + 1
        Loop While Replacements(FindWhat, ReplaceWith)
    FindWhat = Chr(13) & " "
    ReplaceWith = Chr(13)
        Selection.HomeKey Unit:=wdStory
        Do
            LoopsCount = LoopsCount + 1
        Loop While Replacements(FindWhat, ReplaceWith)
    FindWhat = Chr(13) & Chr(13)
    ReplaceWith = Chr(13)
        Selection.HomeKey Unit:=wdStory
        Do
            DoEvents
            LoopsCount = LoopsCount + 1
        Loop While Replacements(FindWhat, ReplaceWith)
    
    MsgBox ("Done after " & LoopsCount & " loops")
End Sub
Private Function Replacements(FindWhat As String, ReplaceWith As String) As Boolean
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = FindWhat
        .Replacement.Text = ReplaceWith
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    
    With Selection
        If .Find.Forward = True Then
            .Collapse Direction:=wdCollapseStart
        Else
            .Collapse Direction:=wdCollapseEnd
        End If
        Replacements = .Find.Execute(Replace:=wdReplaceOne)
    End With
End FunctionSo my code will find forever the string Chr(13) & Chr(13)
I can survive with this (CTRL+Break) but the question remain:
How can I test that I am at the end of document ?
The main unsolved problem is that Word, after I run the code, still not understand where a paragraph start and where is ended (do a try with something copied from www).
So, I waste a lot of time in order to apply styles to certain paragraphs.
Can you help me ?
Thank you !
 
	 
 
		 
 
		