Just found this forum and thought I would see if I could get a little assistance.
I will try to summarize what I am doing.
Lets say I have a word document that is 3 pages long.
Pages 1 and 2 belong together and page 3 should be just a single page.
So via VBA I want to split this document into two documents. Splitting them on different invoice numbers found on the page. one invoice number per page.
Here is how i decide when i want to split, on the page there is a word "INVOICE" then to the right is the invoice number, if page two has same invoice number then I want to append that page to the new document as well. If the invoice number is only on one page then just create a one page document and give document name of the invoice number.
I have some VB/VBA worked up that helps me find my keyword "INVOICE"
Just really looking for a little direction on how i would split the document. And if i go to the second page how i append that to the previous new document.
HOpefully that is clear as mud
Using Office 2003 and will integrate it into vb .net.
Thanks
[VBA]
Dim objWord As New Word.Application
Dim objDoc As Word.Document
objDoc = objWord.Documents.Open(TextBox1.Text)
With objWord.Selection.Find
.Text = "INVOICE"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Do While objWord.Selection.Find.Execute
objWord.Selection.MoveRight(Unit:=wdCharacter, Count:=2)
objWord.Selection.MoveRight(Unit:=wdWord, Count:=4, Extend:=wdExtend)
objWord.Selection.Copy()
MsgBox(objWord.Selection.Information(wdActiveEndPageNumber))
objWord.Selection.GoToNext(wdGoToPage)
Loop
End Sub[/VBA]