Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Jan 2006
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    compiling new document out of several others (Word 2000)

    Hello,

    Yet again a problem I cannot solve... Users need to be able to make one new document out of several other docs (master document wth attachments) They will want to pick them from a list in a userform (made with checkboxes) I've been looking here, found something but I can't get it to work, only the first entry is pasted in the new doc. Where did I go wrong?

    This is the -honestly stolen- code I use:

    Private Sub CmdOK_Click()
    Dim docMast As Document, docTemp As Document
    Dim strFileName As String
    Dim strPath As String
    Dim strFormat As String
    Set docMast = ActiveDocument
    strPath = "G:Impl&SalesdocumentatieFunctionele_beschrijv ing"


    If Me.ChkManInfo Then
    strFileName = Dir(strPath & "Bijlage 1 beschrijving managementrapportages.doc")
    ElseIf Me.ChkDigiLog Then
    strFileName = Dir(strPath & "Bijlage 2 de pati

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: compiling new document out of several others (Word 2000)

    In this bit of code, you assign just one value to strFileName
    <code>
    If Me.ChkManInfo Then
    strFileName = Dir(strPath & "Bijlage 1 beschrijving managementrapportages.doc")
    ElseIf Me.ChkDigiLog Then
    strFileName = Dir(strPath & "Bijlage 2 de pati

  3. #3
    Lounger
    Join Date
    Jan 2006
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: compiling new document out of several others (

    Thanks Stuart,

    This seems to create a new problem: the files to be copied can't be found. I haven't moved them. What could be hapenning? Could it be the differnce between the elseif an the normal 'if-statement?

    Hiope to hear from you,

    Paul

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: compiling new document out of several others (

    Try omitting the Dir function, e.g. change

    strFileName = Dir(strPath & "Bijlage 1 beschrijving managementrapportages.doc")

    to

    strFileName = strPath & "Bijlage 1 beschrijving managementrapportages.doc"

  5. #5
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: compiling new document out of several others (

    If Hans' suggestion doesn't fix this, then can you add
    <code>Msgbox "Filename is: " & strFileName</code>
    just before the line that says
    <code>Set docMast = ActiveDocument</code>
    so we can see what files it is actually looking for.

    StuartR

  6. #6
    Lounger
    Join Date
    Jan 2006
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: compiling new document out of several others (

    Thanks once again, you've set me on the right track.
    This is the code I use now and it works well. The do...loop statement caused several problems so I got rid of that.

    Public docMast As Document, docTemp As Document, strFilename As String, StrPath As String

    Private Sub CmdCancel_Click()
    ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
    End Sub

    Private Sub CmdOK_Click()
    Application.ScreenUpdating = False
    StrPath = "Path"

    If Me.Chkdoc1 Then
    strFilename = StrPath & "doc1.doc"
    VoegDocumentIn
    End If

    If Me.Chkdoc2 Then
    strFilename = StrPath & "Doc2.doc"
    VoegDocumentIn
    End If

    If Me.ChkDoc3 Then
    strFilename = StrPath & "Doc3.doc"
    VoegDocumentIn
    End If

    Selection.EndKey unit:=wdStory
    With ActiveDocument
    .Bookmarks.Add Range:=Selection.Range, Name:="BmkEind"

Posting Permissions

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