ChristopherM
Registered User.
- Local time
- Today, 12:04
- Joined
- Jan 5, 2000
- Messages
- 38
I am using Access 2003 to create text files which are sent to mailing companies. I use FileDialog and SaveAs to get a pathname as in the code below -
Dim dlgSaveAs As FileDialog, PathName As Variant
Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
With dlgSaveAs
.AllowMultiSelect = False
If .Show = False Then Exit Sub
PathName = .SelectedItems(1)
End With
DoCmd.TransferText acExportDelim, , "MailerAddressQuery", _
PathName, True
MsgBox "Postal mailing file created", vbOKOnly
This works fine but when I try to add a filter for txt files only such as this -
Dim dlgSaveAs As FileDialog, PathName As Variant, ffs As FileDialogFilters
Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
With dlgSaveAs
Set ffs = .Filters
With ffs
.Clear
.Add "Text", "*.txt"
End With
.AllowMultiSelect = False
If .Show = False Then Exit Sub
PathName = .SelectedItems(1)
End With
DoCmd.TransferText acExportDelim, , "MailerAddressQuery", _
PathName, True
MsgBox "Postal mailing file created", vbOKOnly
I get a runtime error message "Object doesn't support this property or method". I have tried variations on the filter code with no luck, and have searched MS sites which have no examples of filters with SaveAs but nor do they specifically say you can't use them. Oh, and when I leave the filter code out, the "Save as type" in the file dialog only shows "All Files".
Are "SaveAs" and filters incompatible? Is there a work around? Thanks in advance for any advice anyone can offer.
Dim dlgSaveAs As FileDialog, PathName As Variant
Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
With dlgSaveAs
.AllowMultiSelect = False
If .Show = False Then Exit Sub
PathName = .SelectedItems(1)
End With
DoCmd.TransferText acExportDelim, , "MailerAddressQuery", _
PathName, True
MsgBox "Postal mailing file created", vbOKOnly
This works fine but when I try to add a filter for txt files only such as this -
Dim dlgSaveAs As FileDialog, PathName As Variant, ffs As FileDialogFilters
Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
With dlgSaveAs
Set ffs = .Filters
With ffs
.Clear
.Add "Text", "*.txt"
End With
.AllowMultiSelect = False
If .Show = False Then Exit Sub
PathName = .SelectedItems(1)
End With
DoCmd.TransferText acExportDelim, , "MailerAddressQuery", _
PathName, True
MsgBox "Postal mailing file created", vbOKOnly
I get a runtime error message "Object doesn't support this property or method". I have tried variations on the filter code with no luck, and have searched MS sites which have no examples of filters with SaveAs but nor do they specifically say you can't use them. Oh, and when I leave the filter code out, the "Save as type" in the file dialog only shows "All Files".
Are "SaveAs" and filters incompatible? Is there a work around? Thanks in advance for any advice anyone can offer.