(e-mail address removed) was telling us:
(e-mail address removed) nous racontait que :
Hi. I have two main issues in creating my macro for Word.
I.)
I basically want to copy text that is located in between two strings
of text. Could you guys provide a simple macro for me to do that?
Try something like this. It finds the first occurrence of a target between
two strings, creates a string with it (if necessary), copies the target,
then pastes the target at the end of the current document.
'_______________________________________
Sub FindBetweenTwoStrings()
Dim strOne As String
Dim strTwo As String
Dim strTarget As String
strOne = "Your first string of text"
strTwo = "Your second string of text"
With ActiveDocument.Range
With .Find
.Text = "(" & strOne & ")*(" & strTwo & ")"
.MatchWildcards = True
.Execute
If .Found Then
With .Parent
.MoveStart wdCharacter, Len(strOne)
.MoveEnd wdCharacter, -Len(strTwo)
strTarget = .Text
.Copy
End With
Else
MsgBox "The text was not found.", vbExclamation, _
"Not Found"
Exit Sub
End If
End With
End With
With ActiveDocument.Range
.Collapse wdCollapseEnd
.Paste
End With
End Sub
'_______________________________________
II). I want to know how I can specify a parameter in opening a file.
(I.e. Just changing four characters of the webaddress of the file.)
I have no idea what you are writing about for point II.
Normally, it is better to have two different threads (posts) for two
unrelated questions.
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site:
http://www.word.mvps.org