计算文档中的单词并在单词计数后创建单独的文档 [英] Count Words in Document and Create Separate Documents after a Word Count

查看:65
本文介绍了计算文档中的单词并在单词计数后创建单独的文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个宏,它会在文件中查找指定的分隔符,并且根据该分隔符,它会在每次命中时保存文件。

I have a macro that will look for a specified delimiter in a file and based on that delimiter it will save a file off everytime it hits that.

例如: 

天空是蓝色的。我今天在打棒球。 ||棒球之后你想做什么?我想去看电影。我听说新的蜘蛛侠电影已经播出了。 ||你什么时候去?也许四点左右。我不确定。

The sky is blue. I am playing baseball today. || What do you want to do after baseball. I would like to go to the movies. I heard the new Spider-Man movie is out. || What time do you want to go? Maybe around four. I am not sure.

这会分成3个单独的word文件。第一个文件在第一个分隔符之前有前两个句子,然后下一个文件在第二个分隔符之前有3个句子。最后第三个文件将包含最后3个句子。

This would cut up into 3 separate word files. First file would have the first two sentences before the first delimiter and then the next file would have the 3 sentences before the second delimiter. And finally third file would have the last 3 sentences.

我要做的是不是手动将整个文件中的分隔符放入A)将分隔符放入文件中x(可变)字符数量。或者B)将两个宏合并为1并同时调用两个程序。 

What I am looking to do is instead of manually putting in this delimiter throughout the file to either A) put the delimiter into the file after x (variable) amount of characters. OR B) combine the two macros into 1 and call both procedures at the same time. 

当然有一个警告,我需要确保分隔符没有放入中间句子,所以我需要寻找一定数量的字符,如果计数总数不是句号,感叹号,问号,那么我需要继续
沿着字符串移动,直到它击中下一句话结束。

Of course there is a caveat, I need to make sure that the delimiter is not put in mid sentence so I would need to look for a certain amount of characters and if the count total isn't a period, exclamation point, question mark then I would need to continue moving along the string until it hits the next sentence ending.

我一直试图找到一个起点,但我是VBA的新手。

I have been trying to find a starting point but am new to VBA.

谢谢

Chris

推荐答案

在你想要实现的目标中存在一个根本问题,因为VBA不知道语法句是什么。例如,考虑以下因素:

史密斯先生在约翰博士杂货店花了
There is a fundamental problem in what you're trying to achieve, in that VBA has no idea what a grammatical sentence is. For example, consider the following:
Mr. Smith spent


1,234.56购买:10.25公斤土豆; 10公斤鳄梨;还有15.1公斤格林夫人的山。喜欢澳大利亚坚果。

对于你我来说,这算作一句话;对于VBA,它计为5个句子。
1,234.56 at Dr. John's Grocery Store, to buy: 10.25kg of potatoes; 10kg of avocados; and 15.1kg of Mrs. Green's Mt. Pleasant macadamia nuts.
For you and me, that would count as one sentence; for VBA it counts as 5 sentences.


这篇关于计算文档中的单词并在单词计数后创建单独的文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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