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