master
Wed Jul 12 09:18:31 CDT 2006
Hi and thanks Jean,
While your macro did copy and paste text, it did not copy the correct
text. To make myself clearer let me again outline what I am aiming to
do. Essentially I want to copy some tab separated tables from a large
RTF document. Luckily, most of these tables have a common format so I
should have no problem finding them within a given document. However,
for me to copy the tables I have to specify where they would
essentially begin and end. I thought by specificifying the first word
of the table's title and the last word of the table I could
successfully copy the entire table. Your macro, unfortunately, for some
odd reason does not copy the correct text. I am hoping maybe you or
anyone else for that matter now knows the situation at hand can devise
a macro to deal with my current situation.
Best and Thanks
Jean-Guy Marcil wrote:
> master.investor.2005@gmail.com was telling us:
> master.investor.2005@gmail.com 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
> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> Word MVP site:
http://www.word.mvps.org