![](/img/trans.png)
[英]select a range of text from one Word doc using vba and copy to end of another document and RETAIN formatting
[英]How to copy text from one document to another with same formatting?
我有这段代码可以将一些文本从一个文档复制到一个新文档。
For Each rng In docSource.SpellingErrors
docNew.Range.InsertAfter rng.text & vbCr
Next
总线这不是复制源格式。
我正在尝试使用以下行,但出现错误
预期的函数或变量
docNew.Range.InsertAfter rng.PasteAndFormat(wdPasteDefault) & vbCr
我怎样才能做到这一点? 提前致谢。
下面是一些有错误的测试文本。
When you create a Microsoft Word document for other people to read , it's important to spot and correct any speling mistakes
or gramatical errors you've made. You can let Word's spelling and grammmar
checkers suggest corrections automaticaly while you working , or you can check the spelling and gramar in the the file all
at once when you're finishes writing your document . Microsoft Word 2010 come with some dictionary of standardd grammar and spellings, but they are not comprehensive.
要将内容从一个 Word 文档传输到另一个文档,通常最好使用Range.FormattedText
而不是剪贴板。
所以像这样
Set docNewRange = docNew.Content
For Each rng In docSource.SpellingErrors
docNewRange.FormattedText = rng.FormattedText
docNewRange.Collapse wdCollapseEnd
docNewRange.InsertAfter vbCr
docNewRange.Collapse wdCollapseEnd
Next
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.