From: TimvG on 15 Feb 2010 06:29 I'm trying to so something that seems like it should be simple: move a range down a line. For a selection, this is easy; use Selection.MoveDown or alternatively Selection.Move Unit:=wdLine, Count:=1 I was thinking that it should be much the same for a range. Alas... The MoveDown method is not available for ranges. Ok, so I'll use MyRange.Move Unit:=wdLine, Count:=1 But this returns a "Bad parameter" error. This is weird because all *other* wdUnits seem to work fine with MyRange.Move - e.g. MyRange.Move Unit:=wdRow, Count:=1 works fine. So why do ranges hate wdLine? More generally, how can I move my range down? Any tips appreciated...
From: Pesach Shelnitz on 15 Feb 2010 07:59 Hi, My understanding is that the Range object does not know anything about lines and thus cannot use wdLine. You can get use the Range.Select method to transfer the start and end of a Range object to the Selection object, move down a line using the Selection object, and copy the resultant start and end back to the Range object as in the following. MyRange.Select Selection.MoveDown MyRange.Start = Selection.Start MyRange.End = Selection.End MyRange.Select Selection.Move Unit:=wdLine, Count:=1 MyRange.Start = Selection.Start MyRange.End = Selection.End This virtually eliminates the performance gain from using a Range object, but it can be a workaround in cases where you must do what you described. -- Hope this helps, Pesach Shelnitz My Web site: http://makeofficework.com "TimvG" wrote: > I'm trying to so something that seems like it should be simple: move a > range down a line. > > For a selection, this is easy; use > > Selection.MoveDown > > or alternatively > > Selection.Move Unit:=wdLine, Count:=1 > > I was thinking that it should be much the same for a range. Alas... > > The MoveDown method is not available for ranges. Ok, so I'll use > > MyRange.Move Unit:=wdLine, Count:=1 > > But this returns a "Bad parameter" error. > > This is weird because all *other* wdUnits seem to work fine with > MyRange.Move - e.g. > > MyRange.Move Unit:=wdRow, Count:=1 > > works fine. > > So why do ranges hate wdLine? > > More generally, how can I move my range down? > > Any tips appreciated... > . >
From: TimvG on 15 Feb 2010 16:52 Hi Pesach, Thanks for that. Good to get independent confirmation that range and wdLine don't play nicely. Unfortunately your suggested alternative - using Selection to move the range - doesn't work for me because I'm trying to use a range *rather than* move the Selection. (Why? because moving the Selection causes tables to sometimes redraw in ways I don't want them to.) - Tim On Feb 15, 11:59 pm, Pesach Shelnitz <pesach18(AT)hotmail.com> wrote: > Hi, > > My understanding is that the Range object does not know anything about lines > and thus cannot use wdLine. > > You can get use the Range.Select method to transfer the start and end of a > Range object to the Selection object, move down a line using the Selection > object, and copy the resultant start and end back to the Range object as in > the following. > > MyRange.Select > Selection.MoveDown > MyRange.Start = Selection.Start > MyRange.End = Selection.End > > MyRange.Select > Selection.Move Unit:=wdLine, Count:=1 > MyRange.Start = Selection.Start > MyRange.End = Selection.End > > This virtually eliminates the performance gain from using a Range object, > but it can be a workaround in cases where you must do what you described. > > -- > Hope this helps, > Pesach Shelnitz > My Web site:http://makeofficework.com > > > > "TimvG" wrote: > > I'm trying to so something that seems like it should be simple: move a > > range down a line. > > > For a selection, this is easy; use > > > Selection.MoveDown > > > or alternatively > > > Selection.Move Unit:=wdLine, Count:=1 > > > I was thinking that it should be much the same for a range. Alas... > > > The MoveDown method is not available for ranges. Ok, so I'll use > > > MyRange.Move Unit:=wdLine, Count:=1 > > > But this returns a "Bad parameter" error. > > > This is weird because all *other* wdUnits seem to work fine with > > MyRange.Move - e.g. > > > MyRange.Move Unit:=wdRow, Count:=1 > > > works fine. > > > So why do ranges hate wdLine? > > > More generally, how can I move my range down? > > > Any tips appreciated... > > .
From: Fumei2 via OfficeKB.com on 16 Feb 2010 15:08 It is simple actually. wdLine is a construct of the GUI. In other words, the expression "line" is ONLY applicable to what is on-screen. It is not applicable to a explicit number based object like a Range. Range has a .Start and an .End. These are numbers (character count from Document start), and have NOTHING to do with what is on-screen. A Range.Start to Range.End may cover 1 "line", or 2..... or 4. The number of lines covered is strictly defined by the printer driver, and therefore the GUI. The Range object does not deal with this. Thus, Range does not have a parameter of wdLine, as essentially it is meaningless to Range. 99% of the time, I have found wdLine is never actually needed. A well constructed Word document can use a Range object and deal with paragraphs quite nicely. Or, if this is about tables (as it seems), dealing with Row and Cell objects extremely well. If you post a more explicit description of your situation, it is likely we can suggest how you can use Range effectively. TimvG wrote: >Hi Pesach, > >Thanks for that. Good to get independent confirmation that range and >wdLine don't play nicely. > >Unfortunately your suggested alternative - using Selection to move the >range - doesn't work for me because I'm trying to use a range *rather >than* move the Selection. (Why? because moving the Selection causes >tables to sometimes redraw in ways I don't want them to.) > >- Tim > >> Hi, >> >[quoted text clipped - 56 lines] >> > Any tips appreciated... >> > . -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.aspx/word-programming/201002/1
|
Pages: 1 Prev: Macros get disconnected Next: Reatin Macros in document from template |