Splitting document file from a merged file

Closed
ananth3125 Posts 2 Registration date Thursday October 6, 2011 Status Member Last seen November 24, 2011 - Nov 24, 2011 at 06:40 AM
 Blocked Profile - Nov 25, 2011 at 12:19 AM
Hello,
here i had tried the coding for splitting the document file , guide me the coding to create a new document and to save the content from the input file.

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()


Related:

1 response

Blocked Profile
Nov 25, 2011 at 12:19 AM
Greetings,

Please, bare in mind that before any answer given on the forum, you should know that there are volunteers who give their time trying to solve user problems. They do have a life other than this forum including me.

Therefore, it is specifically requested from Kioskea forum users to show their respect. For this, the use of polite expressions is a minimum.
https://ccm.net/apps-sites/internet-archeology/ccm/10131-terms-of-use-for-ccm-respect-for-others/#politesse

To say please, thank you, appreciate, grateful, etc... is common courtesy when you want something, especially help!

You must copy, modify and repost your message respecting the politeness charter.

We trust that you understand.

Moderator
0