![]() |
|
|
|
#1
|
|||
|
|||
|
Thank you Greg,
The code works perfectly. Code:
Private Sub Document_New()
Dim rng As Range
Dim MainDoc As Document
Dim strFile As Variant
Dim strFolder As String
Set MainDoc = ActiveDocument
strFolder = fcnShellBrowseForFolder
strFile = Dir$(strFolder & "\" & "*.docx")
Do While strFile <> ""
Set rng = MainDoc.Range
rng.Collapse wdCollapseEnd
rng.InsertBreak
rng.InsertFile strFolder & "\" & strFile
strFile = Dir$()
Loop
ActiveDocument.TablesOfContents(1).Update
End Sub
Function fcnShellBrowseForFolder(Optional strTitle As String, Optional strRootFolder As Variant) As String
On Error Resume Next
fcnShellBrowseForFolder = CreateObject("Shell.Application").BrowseForFolder(0, strTitle, 0, strRootFolder).Items.Item.Path
On Error GoTo 0
lbl_Exit:
Exit Function
End Function
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Referencing + Automatic update of Shared Content in MS Word.
|
mitucool | Word | 14 | 10-09-2013 02:08 AM |
How to combine many word files in one file but to have correct pages numbers and tabl
|
Jamal NUMAN | Word | 6 | 04-20-2011 02:32 PM |
SOS - cannot update table of content properly
|
Lee | Word | 5 | 02-04-2011 12:59 PM |
| A Table of Contents that Will Dictate the Content of the File | ddhardy | Word | 0 | 06-23-2010 06:01 AM |
Combine pst files?
|
markg2 | Outlook | 2 | 04-26-2010 03:09 PM |