2011-08-11 5 views
0

webapp는 이미 office2007에서 완료되었으므로 Office2010에서 작동하도록 변환해야합니다. 코드의 헤더 생성기 부분을 변환 할 수 있었지만 문서 본문에 문제가 있습니다. 코드는 "데이터"문서의 데이터를 복사하여 생성 된 문서에 붙여 넣습니다.워드 2010을 자동화하여 문서를 생성합니다

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 디버거를 사용하여 데이터를 볼 때 "{...}"대신 "empty"가됩니다.
코드의 내용이 더 필요하면 누구나 내가 뭘 잘못하고 있는지 말해 줄 수 있습니다.

답변

0

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.

그래서 나는 당신이 여전히 선택된 텍스트가 없다고 생각한다.

당신이 선택 축소 (wdCollapseStart)를 할 수 있을지 궁금하지만, 그것은 단지 생각입니다.

+0

word office 2007에서 작업 한 파일의 모든 텍스트를 선택해야합니다. – Barakonda

관련 문제