Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2003
    Location
    Danbury,ct 06801
    Posts
    24

    Unhappy Unanswered: concatition of two word files

    hi

    i like to concatinated two word file by using VB .. is there a way do ... do it ,,, if it is can you please help me out ....
    hbhavsar

  2. #2
    Join Date
    Jul 2003
    Location
    Portugal
    Posts
    111
    Yes, there is a way.

    See this code and adjust it to your needs.

    ------------------------------------
    Dim wd As Word.Application
    Dim wdDoc As Word.Document
    Dim myFolder As String
    Dim myDoc As String
    Dim MyValue As String

    ' On Error GoTo err_InsertDocs
    Set wd = New Word.Application
    wd.Documents.Add

    wd.Visible = True

    Set wdDoc = wd.ActiveDocument
    myFolder= Application.CurrentProject.Path 'here is where is your .mdb
    myDoc = Dir(myFolder & "*.doc", vbNormal) ' here searchs for all docs
    Do Until myDoc = ""

    ' If you need to configure your PageSetup... else, bypass
    With wdDoc.PageSetup
    wd.Selection.PageSetup.TopMargin = 80.9
    wd.Selection.PageSetup.BottomMargin = 63.8
    wd.Selection.PageSetup.RightMargin = 42.55
    wd.Selection.PageSetup.LeftMargin = 56.7
    wd.Selection.PageSetup.HeaderDistance = 35.45
    wd.Selection.PageSetup.FooterDistance = 39.95
    End With

    wd.Selection.InsertFile myFolder & myDoc
    wd.Selection.InsertBreak

    myDoc = Dir
    Loop

    ' if the last page is blank and if it can be deleted with a backspace, use this
    With wdDoc
    wd.Selection.TypeBackspace
    End With
    ----------------------------------

    I think we need to clear now the memory with

    Set wd = nothing

    Is there an expert to say something about this?

    Regards,

    Ruas

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •