second, the code that calls the function..
================================
================
Dim MyFile As String
Dim MyDir As String
Dim fs
Dim i As Integer
Set fs = Application.FileSearch
With fs
' x = BrowseForFolder(10, "Select a folder")
'Now you will be able to call the Browse for folder dialog by using the following line of code from your program:
' myDir = GetBrowseDirectory(form1)
' myDir = GetBrowseDirectory(Application.ActiveDocument)
MyDir = GetBrowseDirectory()
'...where form1 is the form that will recieve all errormessages. myDir will hold the directory selected or "" (nothing) if selection is cancelled.
If MyDir = "" Then
MsgBox "No folder was selected"
Else
MsgBox "Folder Selected: " & MyDir
.LookIn = MyDir
.FileName = "*.doc"
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Documents.Open FileName:=.FoundFiles(i), ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto
MyFile = .FoundFiles(i)
MyFile = Left$(MyFile, (Len(MyFile)) - 3)
MyFile = MyFile & "html"
ActiveDocument.SaveAs FileName:=MyFile, FileFormat:= _
wdFormatHTML, LockComments:=False, Password:="", AddToRecentFiles:=True, _
WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
' ActiveWindow.View.Type = wdWebView
ActiveDocument.Close
Next iElse
MsgBox "There were no .doc files found."
End If
End If
End With
End Sub
=============================