hi, here i tried the coding for splitting the document file from the merged file,,
i found the problem that a new document is not creating
Dim str1 As String = TextBox1.Text
Dim str2 As String = str1.Replace("[", "") & str1.Replace("]", "")
Dim filename As Object = "f:\" & (Split(System.IO.Path.GetFileName(str2), ".")(0))
Dim obj As Object
Dim regobj As Object
regobj = "\[ITS_*\]*\[/ITS\_*\]"
Dim missing As Object = System.Reflection.Missing.Value
Dim oFals As Object = False
Dim oTru As Object = True
Dim rang As Range
Dim regx As Regex
Dim test As String
Dim unitobj As Object = word.WdUnits.wdStory
Dim ext As Object = word.WdMovementType.wdExtend
Dim savform As Object = word.WdSaveFormat.wdFormatDocument
Dim matchcoll As MatchCollection
obj = TextBox1.Text
objdoc = objapp.Documents.Open(obj, missing, oFals, oTru)
rang = objapp.ActiveDocument.Range
rang.Find.ClearFormatting()
rang.Find.Replacement.ClearFormatting()
rang.Find.Execute(regobj, missing, missing, oTru, missing, missing, oTru)
test = objapp.Selection.Text
Do While rang.Find.Found
' objapp.Selection.HomeKey(unitobj, ext)
Dim filenam As Object = "f:\" & (Split(System.IO.Path.GetFileName(str2), ".")(0))
rang.Select()
matchcoll = Regex.Matches(test, "^\[ITS_(.+?)\]")
objapp.Selection.Cut()
objdoc.Save()
objdoc.Close()
objapp = CreateObject("word.application")
objapp.Visible = False
objdoc = objapp.Documents.Add
objapp.Selection.Paste()
objdoc.SaveAs(filenam, savform)
objdoc.Close()
objdoc = objapp.Documents.Open(obj, missing, oTru, oTru)
rang = objapp.ActiveDocument.Range
rang.Find.ClearFormatting()
rang.Find.Replacement.ClearFormatting()
rang.Find.Execute(regobj, missing, missing, oTru, missing, missing, oTru)
'End If
Loop
objdoc.Close()
objapp.Quit()