I can add documents to create a large document OK with the following code. The problem lies with page numbering. I have an example from Workhorse but I can't get it to work with .Net and word 97. Is this because 97 doesn't support what I'm trying to do. Thanks for any help.
MY CODE
CODE FROM WorkHorseCode:Dim wa As New Word.Application() Dim wdSchedule As New Word.Document() Dim bDone As Boolean m_sFolder = cVariables.PaymentFolder & "Payment Run No - " & m_iPaymentRunID & "\Schedules\" Dim oFS As New DirectoryInfo(m_sFolder) Dim oFile As FileInfo Dim x As Int32 Try For Each oFile In oFS.GetFiles("*ClientProperty Schedule*") If bDone = False Then sbpPaymentText.Text = "Creating file" pbPayment.Value = 5 wdSchedule = wa.Documents.Open(oFile.FullName) wdSchedule.ActiveWindow.Selection.EndKey(Word.WdUnits.wdStory) bDone = True Else sbpPaymentText.Text = "Adding file - " & oFile.Name.ToString pbPayment.Value = pbPayment.Value + 1 wdSchedule.ActiveWindow.Selection.InsertBreak() wdSchedule.ActiveWindow.Selection.InsertFile(FileName:=oFile.FullName, Range:="", ConfirmConversions:=False, Link:=False, Attachment:=False) End If Next Catch ex As Exception MsgBox("Cannot list folders of " & m_sFolder & ":" & ex.ToString) CType(wdSchedule, Word._Document).Close(Word.WdSaveOptions.wdDoNotSaveChanges) CType(wa, Word._Application).Quit(Word.WdSaveOptions.wdDoNotSaveChanges) End Try
http://www.vbforums.com/showthread.p...ord+insertfile
Code:' With primary header/footer for last section... With ActiveDocument _ .Sections(ActiveDocument.Sections.count) _ .Headers(wdHeaderFooterPrimary) ' Don't link to header/footer from previous section. .LinkToPrevious = False ' Start page numbering for section at 1. With .PageNumbers .RestartNumberingAtSection = True .StartingNumber = 1 End With End With




Reply With Quote