Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application.FileDialog

Status
Not open for further replies.

crabback

Technical User
Jan 29, 2007
64
IE
Hi,

I am trying to open a browse window in Word. I think the code should be something like:
Function BrowseFolder() As String
'This opens a browse window and collects path as return value

With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False

If .Show Then
BrowseFolder = .SelectedItems(1) & "\"
End If

End With

End Function

When I run the code I get a compile error on .FileDialog
'Method or Data Member not found.' I thought this meant a reference was not included but I have Microsoft Word 9.0 Object Library & Microsoft Office 9.0 Object Library already included - Am I wrong about the references or am I leaving something out?

Thanks

Crabback
 
Sorry! I should have said I am using Office 2000 on Windows XP



Crabback
 
ok I got it to work with:
Function BrowseFolder(Optional InitDir As String = "") As String

Dim strFolder As String

With Dialogs(wdDialogCopyFile)

If Len(InitDir) > 0 Then

.Directory = InitDir

End If

If .Display <> 0 Then

strFolder = .Directory

If Asc(strFolder) = 34 Then

strFolder = Mid$(strFolder, 2, Len(strFolder) - 2)

End If

BrowseFolder = strFolder

End If

End With

End Function

Crabback
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top