F
Fredrated
My code compiles, but I get 'invalid procedure call or argument' when I try
to use the following code (copied directly from
http://support.microsoft.com/kb/279508 with edits):
Public Function GetFile_Dialog(ByVal starthere As String, ByVal MyTitle As
String, ByVal ftype As String, ByVal fdesc As String) As String
Dim fDialog As Office.FileDialog
Dim varFile As Variant
Dim s As String
'Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
'Allow user to make one selection in dialog box
.AllowMultiSelect = False
'Set the title of the dialog box.
.title = MyTitle
'Clear out the current filters, and add our own.
.Filters.Clear
.Filters.Add fdesc, ftype 'this line errors-out
'Show the dialog box. If the .Show method returns True, the
'user picked at least one file. If the .Show method returns
'False, the user clicked Cancel.
If .Show = True Then
s = .SelectedItems(1)
Else
MsgBox "You clicked Cancel in the file dialog box."
s = ""
End If
End With
GetFile_Dialog = s
End Function
The error occurs at the line:
..Filters.Add fdesc, ftype
hitting the . (dot) after .Filters brings up the methods list, of which
'add' is a member, so how could it be an invalid procedure?
Another question, possibly related, is: when I add 'Microsoft Office N
Object library' to the references list it is Office 12, but all of my other
references are to Office 10!
I have MS Access 2002 SP3 running on XP SP3.
Thanks for any help.
Fred
to use the following code (copied directly from
http://support.microsoft.com/kb/279508 with edits):
Public Function GetFile_Dialog(ByVal starthere As String, ByVal MyTitle As
String, ByVal ftype As String, ByVal fdesc As String) As String
Dim fDialog As Office.FileDialog
Dim varFile As Variant
Dim s As String
'Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
'Allow user to make one selection in dialog box
.AllowMultiSelect = False
'Set the title of the dialog box.
.title = MyTitle
'Clear out the current filters, and add our own.
.Filters.Clear
.Filters.Add fdesc, ftype 'this line errors-out
'Show the dialog box. If the .Show method returns True, the
'user picked at least one file. If the .Show method returns
'False, the user clicked Cancel.
If .Show = True Then
s = .SelectedItems(1)
Else
MsgBox "You clicked Cancel in the file dialog box."
s = ""
End If
End With
GetFile_Dialog = s
End Function
The error occurs at the line:
..Filters.Add fdesc, ftype
hitting the . (dot) after .Filters brings up the methods list, of which
'add' is a member, so how could it be an invalid procedure?
Another question, possibly related, is: when I add 'Microsoft Office N
Object library' to the references list it is Office 12, but all of my other
references are to Office 10!
I have MS Access 2002 SP3 running on XP SP3.
Thanks for any help.
Fred