开发者

automating word 2010 to generate docs

开发者 https://www.devze.com 2023-03-27 03:02 出处:网络
the webapp was already done on office2007 and i need to convert it so it\'ll开发者_运维技巧 work in office2010.

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.


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.

0

精彩评论

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

关注公众号