需要帮助移动范围边界。 [英] Need help moving Range boundaries.

查看:75
本文介绍了需要帮助移动范围边界。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在使用VS2008 SP1,Word 2007。

I'm using VS2008 SP1, Word 2007.

我有以下情况。 我正在使用Range.Relocate()方法移动书签,我遇到了一个问题,当我将一个段落向上移动时,它将进入另一个书签。 我想在
移动的书签之外移动旧书签。 我在旧书签上尝试过Range.SetRange()和Range.MoveStart,但无济于事。有人可以帮帮我吗?

I have the following scenario.  I am moving bookmarks using the Range.Relocate() method and I run into a problem that when I move the range up a paragraph it will go inside another bookmark.  I want to then move the old bookmark outside of the moved bookmark.  I have tried Range.SetRange() and Range.MoveStart on the old bookmark but to no avail. Can anyone please help me out?

这是我为执行书签重定位而创建的方法。

This is the method I created to perform the bookmark relocation.

 


private
 void
 MoveUp(w.Bookmark bookMark, w.Bookmark outerBookmark)
{
	bookMark.Range.Relocate(Convert.ToInt32(w.WdRelocate.wdRelocateUp));
	
	if
 (outerBookmark.Range.Start == bookMark.Range.Start)
	{		
		object
 unit = w.WdUnits.wdCharacter;
		object
 count = bookMark.Range.Characters.Count;
		outerBookmark.Range.MoveStart(ref
 unit, ref
 count);
		//outerBookmark.Range.SetRange(bookMark.Range.End, outerBookmark.Range.End);

	}
}

推荐答案

Hi Diran

Hi Diran

我是害怕我不能很好地关注你的情景,想象一下正在发生什么,或者重现它...这使得很难提供建议。

I'm afraid I'm not following your scenario well enough to envision what's going on, or to reproduce it... That makes it difficult to offer advice.

你是否在想,如果你改变了书签范围的边界,这也应该改变书签的边界?那是不可能的。您需要重新创建书签(Bookmarks.Add方法),为该
书签名称指定新范围。 (由于书签名称在文档中必须是唯一的,因此在其他位置添加名称将删除该名称的原始书签。)

Are you thinking that, if you change the boundaries of a range that's bookmarked, that this should also change the boundaries of the bookmark? That's not possible. You'd need to recreate the bookmark (Bookmarks.Add method), specifying the new Range for that bookmark name. (Since bookmark names must be unique in a document, adding the name elsewhere will delete the original bookmark of that name.)


这篇关于需要帮助移动范围边界。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆