开发者

Analyzing text within a word document - How I can get it to ignore bookmarks?

开发者 https://www.devze.com 2023-04-09 01:02 出处:网络
I have a VSTO add-in 开发者_StackOverflowthat is able to match against specific codes in the body of a document. The codes themselves are just strings that I syntactically match for validation.

I have a VSTO add-in 开发者_StackOverflowthat is able to match against specific codes in the body of a document. The codes themselves are just strings that I syntactically match for validation.

My parsing using StoryRange works fine, but of course, I get the rare exception where a user is doing something funky in their document. I've noticed that some users are introducing bookmarks into the middle of the code string and this throws off my validation match. Instead of of code being '34-RD-345', when you reveal the hidden formatting in Office 2007, you will see something like '34-RID-345'. The bookmark formatting looks similiar to an uppercase i (I) and I can see that a bookmark is present using the bookmark option in the ribbon.

Does anyone know how I might be able to ignore the bookmark when I'm scanning the text?

Maybe an even better alternative maybe to just confine my parsing to [a-Z][0-9]. Is something like that possible?


You can get all bookmarks, then delete them all, then parse the document again.

0

精彩评论

暂无评论...
验证码 换一张
取 消