Sub updateSubdocument() Dim URL(126) As String Dim i, linkCount, subdocCount As Integer Dim position As Integer Dim filepath As String linkCount = ActiveDocument.Hyperlinks.Count subdocCount = ActiveDocument.Subdocuments.Count filepath = ActiveDocument.Path For i = 1 To linkCount position = InStrRev(ActiveDocument.Hyperlinks(i).Address, "\") URL(i) = filepath & "\" & Right(ActiveDocument.Hyperlinks(i).Address, Len(ActiveDocument.Hyperlinks(i).Address) - position) Next i ActiveDocument.Subdocuments.Expanded = Not ActiveDocument.Subdocuments. _ Expanded For Each Subdoc In ActiveDocument.Subdocuments If Subdoc.HasFile = True Then Subdoc.Delete Else MsgBox "このサブ文書は保存されていません。" End If Next Subdoc Selection.EndKey Unit:=wdStory Selection.WholeStory Selection.Delete ActiveDocument.ActiveWindow.View.Type = wdMasterView For i = 1 To linkCount ActiveDocument.Subdocuments.AddFromFile _ Name:=URL(i) Next i If ActiveWindow.View.SplitSpecial = wdPaneNone Then ActiveWindow.ActivePane.View.Type = wdPrintView Else ActiveWindow.View.Type = wdPrintView End If End Sub Sub AutoOpen() Rtn = MsgBox("グループ文書の更新を行います" & Chr(13) & Chr(10) & _ Chr(13) & Chr(10) & _ "『サブ文書なしでグループ文書を開きますか?』" & Chr(13) & Chr(10) & _ "のメッセージが表示された場合「はい(Y)」を選んでください", vbOKCancel, "グループ文書の更新") If Rtn = vbOK Then Call updateSubdocument Else ' End If End Sub
posted at 2004/02/14