Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-07-2021, 05:26 AM
mc1903 mc1903 is offline Word VBA. How best to insert sections of other documents into a main document. Windows 10 Word VBA. How best to insert sections of other documents into a main document. Office 2016
Novice
Word VBA. How best to insert sections of other documents into a main document.
 
Join Date: Jan 2019
Posts: 8
mc1903 is on a distinguished road
Question Word VBA. How best to insert sections of other documents into a main document.

Hello,



I am looking for advice on the best approach to a challenge I have today.

I have a main Word document that I would like to insert sections of other Word documents (I'll call these documents 'snippets') into, to build out a boilerplate.

All documents (main & snippets) are built from the same template, so styles, etc are identical.

In each of my snippet documents, the section I wish to insert is currently bounded by simple text tags {start} & {end} each on their own otherwise blank pages. If there is a better way to identify the wanted section in each snippet doc, then I am open to changing from text tags.

I have some VBA working to give me a dialog box where I can select the multiple snippet documents and currently I am just outputting the full path of each file to Debug.Print. I am not sure how to process each snippet document, to locate the section between the tags, and insert it into the main doc.

Code:
Sub SelectSnippetFiles()
 
    Dim mfd As FileDialog
    Dim FileChosen As Integer
    Dim i As Integer
    Set mfd = Application.FileDialog(msoFileDialogFilePicker)
        mfd.InitialView = msoFileDialogViewList
        mfd.AllowMultiSelect = True
    FileChosen = mfd.Show
    
    If FileChosen = -1 Then
        For i = 1 To mfd.SelectedItems.Count
            Debug.Print mfd.SelectedItems(i)
            'I need something here to process the snippet sections :-/
        Next i
    End If

 End Sub
If anyone could give me a few pointers, I would be really grateful.

I am using Office 365, so have pretty much the latest version.

Thanks
M
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word VBA. How best to insert sections of other documents into a main document. insert multiple word docs into main word doc MimiCush Word 4 03-26-2018 01:07 PM
How to insert a section in the middle of a Word document, but keep the sections around it continuous vspofford Word 3 01-30-2016 01:19 PM
Can Word highlight the same text in the Reviewing Pane as in the main document? wordistheword Word 4 09-09-2013 04:50 AM
How to insert full documents into existing word document Laraak Word 1 03-07-2013 11:59 PM
Connecting documents to main document themangoagent Word 1 08-07-2009 10:15 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:43 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft