![]() |
|
|
|
#1
|
||||
|
||||
|
If you just want to create a file list by folder, try:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim StrFolder As String
' Browse for the starting folder
StrFolder = GetTopFolder
If StrFolder = "" Then Exit Sub
StrFolder = StrFolder & "\*.doc"
If UBound(Split(CreateObject("wscript.shell").Exec("Cmd /c Dir """ & StrFolder & """ /B/S").StdOut.ReadAll, vbCrLf)) > 0 Then
ActiveDocument.Range.Text = CreateObject("wscript.shell").Exec("Cmd /c Dir """ & StrFolder & """ /B/S").StdOut.ReadAll
End If
Application.ScreenUpdating = True
End Sub
Function GetTopFolder() As String
Dim oFolder As Object
GetTopFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetTopFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
For PC macro installation & usage instructions, see: Installing Macros PS: Please update your user profile; I seriously doubt you're running Office 2007 on Windows XP.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| MS Word Error: This file is in use by another application or user | conky | Word | 4 | 02-26-2019 09:21 AM |
Inserting pictures in a word document launched from another application
|
Fritesmodern | Word VBA | 2 | 11-13-2017 02:21 PM |
| Opening a MS .dot file through ASP.Net application | eljapo4 | Word | 0 | 09-14-2012 01:11 AM |
Application not found error when trying to open .pdf files.
|
Dave | Outlook | 2 | 12-15-2005 01:01 PM |
access runtime application will not install
|
markjean | Office | 1 | 12-06-2005 02:15 AM |