From: clara on 28 Apr 2010 11:55 HI Graham, I've copied your code into my module created VB 2005, on this line oRng.Collapse wdCollapseEnd the "wdCollapseEnd" was underlined as not declared, maybe there is a mismatch between VBA and .NET Thank you Clara -- thank you so much for your help "Graham Mayor" wrote: > What do you want to do with the data having found it? The following macro > will locate the data in square brackets that matches your layout and assigns > it in turn to a range variable oRng. You can do what you want with that > range eg display it in a message box as in the example > > Dim oRng As Range > Set oRng = ActiveDocument.Range > With oRng.Find > .Text = "\[[0-9A-Z]{1,}\]" > Do While .Execute(Forward:=True, _ > MatchWildcards:=True) = True > oRng.Start = oRng.Start + 1 > oRng.End = oRng.End - 1 > 'orng is the text in the brackets e.g. > MsgBox oRng > oRng.Collapse wdCollapseEnd > Loop > End With > > > If you want it to find *anything* between square brackets change the line > .Text = "\[[0-9A-Z]{1,}\]" > to > .Text = "\[*\]" > > -- > <>>< ><<> ><<> <>>< ><<> <>>< <>><<> > Graham Mayor - Word MVP > > My web site www.gmayor.com > Word MVP web site http://word.mvps.org > <>>< ><<> ><<> <>>< ><<> <>>< <>><<> > > > > "clara" <clara(a)discussions.microsoft.com> wrote in message > news:CF3CCE93-4E49-4F13-B29E-4C78024A6785(a)microsoft.com... > > Hi all, > > > > I have some data scattered in a word doc, but fortunately the data is > > formated like R12345 and embraced inside [ ] like [R12345], in order to > > retrieve value R12345 , > > what am I going to do. > > > > > > thank you so much for your help > > > > Clara > > > . >
From: clara on 28 Apr 2010 12:16 Hi Graham, I got it. In .NET it should be translated into: Collapse(Word.WdCollapseDirection.wdCollapseEnd) but what does this enum wdCollapseEnd mean? Clara Thank you "Graham Mayor" wrote: > What do you want to do with the data having found it? The following macro > will locate the data in square brackets that matches your layout and assigns > it in turn to a range variable oRng. You can do what you want with that > range eg display it in a message box as in the example > > Dim oRng As Range > Set oRng = ActiveDocument.Range > With oRng.Find > .Text = "\[[0-9A-Z]{1,}\]" > Do While .Execute(Forward:=True, _ > MatchWildcards:=True) = True > oRng.Start = oRng.Start + 1 > oRng.End = oRng.End - 1 > 'orng is the text in the brackets e.g. > MsgBox oRng > oRng.Collapse wdCollapseEnd > Loop > End With > > > If you want it to find *anything* between square brackets change the line > .Text = "\[[0-9A-Z]{1,}\]" > to > .Text = "\[*\]" > > -- > <>>< ><<> ><<> <>>< ><<> <>>< <>><<> > Graham Mayor - Word MVP > > My web site www.gmayor.com > Word MVP web site http://word.mvps.org > <>>< ><<> ><<> <>>< ><<> <>>< <>><<> > > > > "clara" <clara(a)discussions.microsoft.com> wrote in message > news:CF3CCE93-4E49-4F13-B29E-4C78024A6785(a)microsoft.com... > > Hi all, > > > > I have some data scattered in a word doc, but fortunately the data is > > formated like R12345 and embraced inside [ ] like [R12345], in order to > > retrieve value R12345 , > > what am I going to do. > > > > > > thank you so much for your help > > > > Clara > > > . >
From: Doug Robbins - Word MVP on 28 Apr 2010 17:22 It collapses the range to its end (so that in effect, it does not contain anything); handy though if you want to get hold of something after the end of the range, or prevent do code from going into an endless loop because it continues to act upon the initial range. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "clara" <clara(a)discussions.microsoft.com> wrote in message news:ABF0B9A8-CCF5-4BF2-B0FD-3E83EBED7F15(a)microsoft.com... > Hi Graham, > > I got it. In .NET it should be translated into: > > Collapse(Word.WdCollapseDirection.wdCollapseEnd) > > but what does this enum wdCollapseEnd mean? > > Clara > > Thank you > > > "Graham Mayor" wrote: > >> What do you want to do with the data having found it? The following macro >> will locate the data in square brackets that matches your layout and >> assigns >> it in turn to a range variable oRng. You can do what you want with that >> range eg display it in a message box as in the example >> >> Dim oRng As Range >> Set oRng = ActiveDocument.Range >> With oRng.Find >> .Text = "\[[0-9A-Z]{1,}\]" >> Do While .Execute(Forward:=True, _ >> MatchWildcards:=True) = True >> oRng.Start = oRng.Start + 1 >> oRng.End = oRng.End - 1 >> 'orng is the text in the brackets e.g. >> MsgBox oRng >> oRng.Collapse wdCollapseEnd >> Loop >> End With >> >> >> If you want it to find *anything* between square brackets change the line >> .Text = "\[[0-9A-Z]{1,}\]" >> to >> .Text = "\[*\]" >> >> -- >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<> >> Graham Mayor - Word MVP >> >> My web site www.gmayor.com >> Word MVP web site http://word.mvps.org >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<> >> >> >> >> "clara" <clara(a)discussions.microsoft.com> wrote in message >> news:CF3CCE93-4E49-4F13-B29E-4C78024A6785(a)microsoft.com... >> > Hi all, >> > >> > I have some data scattered in a word doc, but fortunately the data is >> > formated like R12345 and embraced inside [ ] like [R12345], in order >> > to >> > retrieve value R12345 , >> > what am I going to do. >> > >> > >> > thank you so much for your help >> > >> > Clara >> >> >> . >>
From: clara on 30 Apr 2010 15:56 Hi Doug, it is a real handy feature, thank you Clara have a nice weekend "Doug Robbins - Word MVP" wrote: > It collapses the range to its end (so that in effect, it does not contain > anything); handy though if you want to get hold of something after the end > of the range, or prevent do code from going into an endless loop because it > continues to act upon the initial range. > > -- > Hope this helps. > > Please reply to the newsgroup unless you wish to avail yourself of my > services on a paid consulting basis. > > Doug Robbins - Word MVP, originally posted via msnews.microsoft.com > > "clara" <clara(a)discussions.microsoft.com> wrote in message > news:ABF0B9A8-CCF5-4BF2-B0FD-3E83EBED7F15(a)microsoft.com... > > Hi Graham, > > > > I got it. In .NET it should be translated into: > > > > Collapse(Word.WdCollapseDirection.wdCollapseEnd) > > > > but what does this enum wdCollapseEnd mean? > > > > Clara > > > > Thank you > > > > > > "Graham Mayor" wrote: > > > >> What do you want to do with the data having found it? The following macro > >> will locate the data in square brackets that matches your layout and > >> assigns > >> it in turn to a range variable oRng. You can do what you want with that > >> range eg display it in a message box as in the example > >> > >> Dim oRng As Range > >> Set oRng = ActiveDocument.Range > >> With oRng.Find > >> .Text = "\[[0-9A-Z]{1,}\]" > >> Do While .Execute(Forward:=True, _ > >> MatchWildcards:=True) = True > >> oRng.Start = oRng.Start + 1 > >> oRng.End = oRng.End - 1 > >> 'orng is the text in the brackets e.g. > >> MsgBox oRng > >> oRng.Collapse wdCollapseEnd > >> Loop > >> End With > >> > >> > >> If you want it to find *anything* between square brackets change the line > >> .Text = "\[[0-9A-Z]{1,}\]" > >> to > >> .Text = "\[*\]" > >> > >> -- > >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<> > >> Graham Mayor - Word MVP > >> > >> My web site www.gmayor.com > >> Word MVP web site http://word.mvps.org > >> <>>< ><<> ><<> <>>< ><<> <>>< <>><<> > >> > >> > >> > >> "clara" <clara(a)discussions.microsoft.com> wrote in message > >> news:CF3CCE93-4E49-4F13-B29E-4C78024A6785(a)microsoft.com... > >> > Hi all, > >> > > >> > I have some data scattered in a word doc, but fortunately the data is > >> > formated like R12345 and embraced inside [ ] like [R12345], in order > >> > to > >> > retrieve value R12345 , > >> > what am I going to do. > >> > > >> > > >> > thank you so much for your help > >> > > >> > Clara > >> > >> > >> . > >>
First
|
Prev
|
Pages: 1 2 Prev: I want to catch the "Save on Exit" routine Next: Assigning delete text macro to check box |