在vb.net中分割一个doc文件 [英] split a doc file in vb.net

查看:59
本文介绍了在vb.net中分割一个doc文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我可以锻炼合并和拆分多个Word文档.

完成合并功能后,(所有Word文档都可以与其合并,并在其内容的开头和结尾包含其文件名),并且我希望能够将合并的文档拆分为以前的格式(合并之前).

我附加了合并多个Word文档.
我可以在该项目中使用vb.net.

Hi,

I could workout merge and split a multiple word document.

As I have finished the merge function, (All word document can merge with include its file name in beginning and back of its content), and I want to be able to split the merged document in previous (before merging) format.

I attach merging multiple word document.
I could use vb.net to this project.

Dim arraylist(100) As String
            Dim oFals As Object = False
            Dim oTru As Object = True
            Dim obj2 As Object = WdSaveFormat.wdFormatDocument
            Dim missing As Object = System.Reflection.Missing.Value
            object1 = TextBox1.Text & "\MERGED DOCUMENT"
            Dim i As Integer
            Dim formt As Object = WdOpenFormat.wdOpenFormatDocument
            Dim obj As Object
            Dim wat1 As Object = word.WdGoToItem.wdGoToLine
            Dim wich As Object = word.WdGoToDirection.wdGoToLast
            Dim wat As Object = word.WdUnits.wdStory
            Dim moov As Object = word.WdMovementType.wdMove
            Dim str As Integer = 1
            objapp = CreateObject("word.Application")
            objapp.Visible = False
            objdoc = objapp.Documents.Add
            objdoc.SaveAs(object1, obj2)
            ''LOOPING THE LISTBOX TIEMS TO A ARRAYLIST ''
            For i = 0 To ListBox2.Items.Count - 1
                arraylist(i) = ListBox2.Items(i)
                obj = arraylist(i)
                ''OPENING A DOCUMENT IN THE ARRAY LIST(LISTBOX ITEMS)''
                objdoc = objapp.Documents.Open(obj, missing, oFals, oTru) ', "", "", oFals, "", "", formt, "", "", "", "", "", "")
                objapp.Selection.WholeStory()
                objapp.Selection.Copy()
                objdoc.Close()
                '' OPENING A NEW DOCUMENT ''
                objdoc = objapp.Documents.Open(object1, missing, oFals, oTru) ', "", "", oFals, "", "", formt, "", "", "", "", "", "")
                objapp.Selection.EndKey(wat, moov)
                ''INSERTING TAG TO THE START OF THE DOCUMENT''
                Dim s1 As String = "<filename">
                objapp.Selection.TypeParagraph()
                objapp.Selection.TypeText(s1)
                objapp.Selection.TypeParagraph()
                objapp.Selection.Paste()
                ''INSERTING TAG TO THE END OF THE DOCUMENT''
                Dim s2 As String = "
                objapp.Selection.TypeText(s2)
                objapp.Selection.TypeParagraph()
                str = str + 1
                objdoc.Save()
                objdoc.Close()
            Next i
            objapp.Quit()

推荐答案

我用以下编码完成了Word文件的拆分

I done word file splitting in below coding

objdoc = objapp.Documents.Open(obj, missing, oFals, oTru)
        range = objapp.ActiveDocument.Range
        range.Find.ClearFormatting()
        range.Find.Replacement.ClearFormatting()
        range.Find.Execute(regobj, missing, missing, oTru, missing, missing, oTru)
        Do While rang.Find.Found
            range.Select()
            matchcollection = Regex.Matches(tet, "^\[ITS_(.+?)\]")
            objapp.Selection.Cut()
            objdoc.SaveAs()
            objdoc.Close()
            objapp = CreateObject("word.Application")
            objapp.Visible = False
            objdoc = objapp.Documents.Add
            objapp.Selection.Paste()
            objdoc.SaveAs(obj1, obj2)
            objdoc.Close()
        Loop


这篇关于在vb.net中分割一个doc文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆