自动使用 Word 2010 生成文档

发布于 2024-11-29 14:05:26 字数 637 浏览 2 评论 0原文

该网络应用程序已经在office2007上完成,我需要对其进行转换,以便它可以在office2010中工作。 我能够转换代码的标头生成器部分,但我对文档本身的正文有问题。该代码从“数据”文档复制数据并将其粘贴到生成的文档中。

appword.activewindow.activepane.view.seekview = 0
    'set appsel1 = appword.activewindow.selection
    set appsel1 = appword.window(filepath).selection        -that is the original one
    appdoc1.bookmarks("b1").select
    appword.selection.insertafter("some text")
    appsel1.endkey(6)         -the code stops here
    appword.selection.insertafter("some other text")

iexplorer 调试器显示错误:需要 appsel1 对象。当我使用 iexplorer 调试器查看其数据时,其数据为“空”而不是“{...}”
谁能告诉我我做错了什么
如果您需要更多代码,请告诉我。

the webapp was already done on office2007 and i need to convert it so it'll work in office2010.
i was able to convert the header generator part of the code but i have problem with the body of the doc itself. the code copy the data from a "data" doc and paste it into the generated doc.

appword.activewindow.activepane.view.seekview = 0
    'set appsel1 = appword.activewindow.selection
    set appsel1 = appword.window(filepath).selection        -that is the original one
    appdoc1.bookmarks("b1").select
    appword.selection.insertafter("some text")
    appsel1.endkey(6)         -the code stops here
    appword.selection.insertafter("some other text")

the iexplorer debuger says ERROR:appsel1 object required. and when i view its data using the iexplorer debugger its data is "empty" instead of "{...}"
can anyone tell me what i'm doing wrong
if you need more of the code tell me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空‖城人不在 2024-12-06 14:05:26

来自 MSDN

应用此方法后,选择范围将扩大以包括新的
文本。

如果您将此方法用于引用整个内容的选择
段落,文本插入到结束段落标记(
文本将出现在下一段的开头)。插入
段落末尾的文本,确定结束点并
从此位置减 1(段落标记为一个字符)。

但是,如果选择以段落标记结束,也会发生这种情况
作为文档的结尾,Microsoft Word 在之前插入文本
最后的段落标记而不是创建一个新的段落
文档结束。

此外,如果所选内容是书签,Word 会插入指定的书签
文本,但不会扩展选择或书签以包括
新文本。

所以我怀疑您仍然没有选定的文本。

我想知道您是否可以执行 Selection Collapse(wdCollapseStart) 但这只是一个想法。

From MSDN

After this method is applied, the selection expands to include the new
text.

If you use this method with a selection that refers to an entire
paragraph, the text is inserted after the ending paragraph mark (the
text will appear at the beginning of the next paragraph). To insert
text at the end of a paragraph, determine the ending point and
subtract 1 from this location (the paragraph mark is one character).

However, if the selection ends with a paragraph mark that also happens
to be the end of the document, Microsoft Word inserts the text before
the final paragraph mark rather than creating a new paragraph at the
end of the document.

Also, if the selection is a bookmark, Word inserts the specified
text but does not extend the selection or the bookmark to include the
new text.

So I suspect that you still have no selected text.

I wonder if you can do a Selection Collapse(wdCollapseStart) but that's just a thought.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文