none
series of documents all needing same basic info RRS feed

  • Question

  • i have a series of documents that form contracts, all needing same basic info on contract details. how can i automatically insert data into all the documents in one go instead of having to personalise each one separately?  i cannot see how mail merge or hyperlinks will work as i am going to have to do this for every contract so hyperlinks would copy over to all docs and i would only want those specific to that contract.  i have about 10/12 documents to prepare for each contract.
    Friday, January 10, 2014 4:17 PM

Answers

  • Hi Janey

    Which version of Word are you using?

    Are you familiar with the concept of "templates", in Word meaning *.dotx files that can be used as the basis to create new documents? If you are familiar with templates, please elaborate on how they fall short for your requirements.

    Are you familiar with term "Building Block" or "AutoText"?

    Do you have any programming background (since you post in a developer forum, the assumption is that you feel you need code to accomplish what you need to do)?


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, January 10, 2014 5:09 PM
    Moderator
  • Hi,

    According to your description, I’m not sure about the information and the location you want to insert into your contract.

    As Cindy said, if the contract with all the same format and basic info, you could resort to Word Template to create a contract template, and then all the other new document could be created based on this template.

    If you want to develop a VBA macro to achieve the goal, you should provide more details about your contract and requirement.

    Here is a sample to open a folder and then you could choose the documents which you want to modify. The VBA macro will insert a string after the first paragraph in every selected documents. You could edit it as you want.

    Sub main()
    Const msoFileDialogOpen = 1
    
    Set objWord = CreateObject("Word.Application")
    
    objWord.ChangeFileOpenDirectory ("C:\Users\Documents")
    
    objWord.FileDialog(msoFileDialogOpen).Title = "Select the files to be modify"
    objWord.FileDialog(msoFileDialogOpen).AllowMultiSelect = True
    
    If objWord.FileDialog(msoFileDialogOpen).Show = -1 Then
        objWord.WindowState = 2
        For Each objFile In objWord.FileDialog(msoFileDialogOpen).SelectedItems
            ImportWordTable objFile
        Next
    End If
    
    objWord.Quit
    End Sub
    
    Sub ImportWordTable(wdFileName As Variant)
    Dim wdDoc As Object
    
    If wdFileName = "" Then Exit Sub '(user cancelled import file browser)
    
    wdDoc = GetObject(wdFileName) 'open Word file
    With wdDoc
        With .Paragraphs(1).Range
            .InsertAfter "insert some string"
            .InsertParagraphAfter
        End With
    
        .Save
    End With
    wdDoc.Close
    wdDoc = Nothing
    End Sub

    >> i cannot see how mail merge or hyperlinks will work as i am going to have to do this for every contract so hyperlinks would copy over to all docs and i would only want those specific to that contract.  <<

    What’s the meaning of this sentence?

    About mail merge you could refer to the link: How to use mail merge to create form letters in Word


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, January 13, 2014 9:16 AM
    Moderator

All replies

  • Hi Janey

    Which version of Word are you using?

    Are you familiar with the concept of "templates", in Word meaning *.dotx files that can be used as the basis to create new documents? If you are familiar with templates, please elaborate on how they fall short for your requirements.

    Are you familiar with term "Building Block" or "AutoText"?

    Do you have any programming background (since you post in a developer forum, the assumption is that you feel you need code to accomplish what you need to do)?


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, January 10, 2014 5:09 PM
    Moderator
  • Hi,

    According to your description, I’m not sure about the information and the location you want to insert into your contract.

    As Cindy said, if the contract with all the same format and basic info, you could resort to Word Template to create a contract template, and then all the other new document could be created based on this template.

    If you want to develop a VBA macro to achieve the goal, you should provide more details about your contract and requirement.

    Here is a sample to open a folder and then you could choose the documents which you want to modify. The VBA macro will insert a string after the first paragraph in every selected documents. You could edit it as you want.

    Sub main()
    Const msoFileDialogOpen = 1
    
    Set objWord = CreateObject("Word.Application")
    
    objWord.ChangeFileOpenDirectory ("C:\Users\Documents")
    
    objWord.FileDialog(msoFileDialogOpen).Title = "Select the files to be modify"
    objWord.FileDialog(msoFileDialogOpen).AllowMultiSelect = True
    
    If objWord.FileDialog(msoFileDialogOpen).Show = -1 Then
        objWord.WindowState = 2
        For Each objFile In objWord.FileDialog(msoFileDialogOpen).SelectedItems
            ImportWordTable objFile
        Next
    End If
    
    objWord.Quit
    End Sub
    
    Sub ImportWordTable(wdFileName As Variant)
    Dim wdDoc As Object
    
    If wdFileName = "" Then Exit Sub '(user cancelled import file browser)
    
    wdDoc = GetObject(wdFileName) 'open Word file
    With wdDoc
        With .Paragraphs(1).Range
            .InsertAfter "insert some string"
            .InsertParagraphAfter
        End With
    
        .Save
    End With
    wdDoc.Close
    wdDoc = Nothing
    End Sub

    >> i cannot see how mail merge or hyperlinks will work as i am going to have to do this for every contract so hyperlinks would copy over to all docs and i would only want those specific to that contract.  <<

    What’s the meaning of this sentence?

    About mail merge you could refer to the link: How to use mail merge to create form letters in Word


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, January 13, 2014 9:16 AM
    Moderator
  • Maybe this will help: http://gregmaxey.mvps.org/word_tip_pages/doc_bundler.html

    Greg Maxey Please visit my website at: http://gregmaxey.mvps.org/word_tips.htm

    Monday, January 13, 2014 6:00 PM