java在文档末尾添加_如何在打开表单后将子文件添加到Word文档的末尾?
我'm trying to write a macro that adds subdocuments to the end of a Word document when the Word document is opened. The document in question already has some text in it, so before running the macro I' d喜歡將光標移動到文檔的末尾 . 我可以使用代碼實現這一點: Selection.EndKey Unit:=wdStory 在打開文檔后運行宏時工作正常,但是如果我在使用Sub打開文檔后立即運行宏:
Private Sub Document_Open()
Selection.EndKey Unit:=wdStory
'Add subdocuments based on user input to a form
'(See edit below)
End Sub
在ThisDocument對象中,子文檔添加在文檔的開頭 . 這可能是因為光標還沒有出現所以 Selection 還沒有't '存在 .
如何在文檔打開時運行我的宏,但是將子文檔添加到文檔的末尾?
我先嘗試寫出一個空格,使光標產生但沒有變化......
對替代方法的任何建議也歡迎 .
編輯:ThisDocument中的此代碼:
Private Sub Document_Open()
CreateWorkbook.Show
End Sub
調用表單CreateWorkbook,點擊子按鈕:
Private Sub GenerateButton_Click()
Dim i As Integer
Dim rng As Word.Range
Set rng = ActiveDocument.Content
rng.Collapse wdCollapseEnd
'ModulesListBox is a user input box that is a list of paths to the subdocuments
For i = 0 To ModulesListBox.ListCount - 1
docpath = ModulesListBox.List(i)
rng.Subdocuments.AddFromFile docpath
Next i
End Sub
總結
以上是生活随笔為你收集整理的java在文档末尾添加_如何在打开表单后将子文件添加到Word文档的末尾?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用php实现随机点名,使用javascr
- 下一篇: 内联命名空间(inline namesp