Naturally, often modify them.
I feel it is wasted to repeat writing same sentences,pasting charts and tables modified a little.
So I use VBA of WORD.
At first , I make a report template manually.
And I set "Bookmark" to a group of senetence which I think will modify.
(WORD MENU :"Insert > Bookmark")
When I need to modify some group of senetences, I run VBA Program.
Sub TryCode() Dim tmpObjBookmark As Bookmark Dim tmpBookmarkName As String Dim tmpRangeStartNumber As Long Dim tmpNewText As String Dim tmpNewTextLength As Long Dim tmpObjRange As Word.Range tmpNewText = "BBBBB" & vbCrLf & "DDD" For Each tmpObjBookmark In ActiveDocument.Bookmarks If tmpBookmarkName <> tmpObjBookmark.name Then tmpBookmarkName = tmpObjBookmark.Name tmpRangeStartNumber = tmpObjBookmark.Start tmpNewTextLength = Len(tmpNewText) Set tmpObjRange = ActiveDocument.Range(tmpRangeStartNumber, tmpRangeStartNumber + tmpNewTextLength) tmpObjBookmark.Range.Text = tmpNewText Call ActiveDocument.Bookmarks.Add(tmpBookmarkName, tmpObjRange) End If Next tmpObjBookmark End Sub
0 件のコメント:
コメントを投稿