Results 1 to 2 of 2

Thread: How to Insert Section from Source Doc into Target Doc

  1. #1

    Question How to Insert Section from Source Doc into Target Doc

    Hello all,

    I am looking for help inserting a full section from a source doc into a target document.

    For example:

    "3. SECTION HEADING EXAMPLE
    3.1 Text here
    3.2 Text here
    3.3 Text here
    Table here:
    Table Heading Text
    Text Text
    Image Image
    3.4 Text here"

    I need the section from the source document to be pasted into a specific area in the target document, for example, between "2. SECTION HEADING EXAMPLE" and "4. SECTION HEADING EXAMPLE"

    I know this is possible because I used a code that did this previously but I cannot find it. I have a code that this sub will be inserted into that loops through all documents in a folder and performs a subroutine -- it will open all documents in a folder, perform the action, and close the document. All the documents need this specific section added between existing Section X and Y.

    Thank you for any help you can provide!

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,103
    Location
    Welcome to VBAX iwritedoc62. Until one of the word guru's drops by, perhaps this will get you started in the right direction

    Sub InsertAfterMethod()
      Dim MyText As String
      Dim MyRange As Object
      Set MyRange = ActiveDocument.Range
      MyText = "<Replace this with your text>"
      ' Selection Example:
      Selection.InsertAfter (MyText)
      ' Range Example:
      ' (Inserts text at the current position of the insertion point.)
      MyRange.Collapse
      MyRange.InsertAfter (MyText)
    End Sub


    Yes, it doesn't loop through your documents, but if you wish to test it and see if it can be modified.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Tags for this Thread

Posting Permissions

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