JanAdam
Mon Jan 16 14:07:02 CST 2006
Thanks again Helmut, or can I say Viel Dank?
I will try it. By the way, reading the page you suggested was not that
difficult as thought it would be. I think I can make most of it. I see that
you repeat DoEvents in a loop until ShellX is done. Nice.
Steve, thank you too. It is very nice to receive so much support and sound
advice.
Much appreciated.
--
JanAdam
"Steve Yandl" wrote:
> JanAdam,
>
> See if this doesn't get you close to what you want to do, even though it
> doesn't use dir.
>
> Sub FolderBrowse()
> Dim objPath As String
> Dim docNew As Word.Document
> Const WINDOW_HANDLE = 0
> Const NO_OPTIONS = 0
>
> On Error Resume Next
> Set objShell = CreateObject("Shell.Application")
> Set objFolder = objShell.BrowseForFolder _
> (WINDOW_HANDLE, "Select a folder:", NO_OPTIONS, "C:\")
> Set objFolderItem = objFolder.Self
> objPath = objFolderItem.Path
> Err.Clear
>
> Set fso = CreateObject("Scripting.FileSystemObject")
>
> If Len(objPath) > 0 Then
> Set docNew = Documents.Add
>
> With docNew
> Set fdrFolder = fso.GetFolder(objPath)
> If fdrFolder.Files.Count > 0 Then
> Selection.TypeText "Files contained in " & objPath
> Selection.TypeParagraph
> For Each filFile In fdrFolder.Files
> Selection.TypeText fso.GetFileName(filFile)
> Selection.TypeParagraph
> Next filFile
> Else
> Selection.TypeText "No files in " & objPath
> Selection.TypeParagraph
> End If
>
> If fdrFolder.Subfolders.Count > 0 Then
> Selection.TypeText "Subfolders contained in " & objPath
> Selection.TypeParagraph
> For Each fdrSubFolder In fdrFolder.Subfolders
> Selection.TypeText fso.GetFileName(fdrSubFolder)
> Selection.TypeParagraph
> Next fdrSubFolder
> Else
> Selection.TypeText "No subfolders in " & objPath
> Selection.TypeParagraph
> End If
>
> End With
>
> Else
> Exit Sub
> End If
>
> Set objShell = Nothing
> Set fso = Nothing
>
> End Sub
>
>
>
> Steve
>
>
>
> "JanAdam" <JanAdam@discussions.microsoft.com> wrote in message
> news:C3CC9E6C-0BB3-4FD0-B94A-F58C240EC12E@microsoft.com...
> > Thank you all for your help. It will keep me busy for a while.
> > Would *DoEvents* after Helmut's Shell command take care
> > of the timing issues?
> > Helmut: unfortunately my German is barely good enough to
> > order a beer but is by far too limited for a technical text.
> >
> > --
> > JanAdam
> >
> >
> > "Helmut Weber" wrote:
> >
> >> Hi everybody,
> >>
> >> just in case somebody needs "shell" for whatever reason,
> >> and has to wait until the command has been completed.
> >>
> >>
http://vb-tec.de/xshell.htm
> >>
> >> Unfortunatly, this page is in german.
> >>
> >> By the way, the function is called "shellx",
> >> not "xshell", as the address indicates.
> >>
> >> --
> >> Greetings from Bavaria, Germany
> >>
> >> Helmut Weber, MVP WordVBA
> >>
> >> Win XP, Office 2003
> >> "red.sys" & Chr$(64) & "t-online.de"
> >>
>
>
>